Skip to main content

Questions tagged [r]

Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer, & (b) is not *just* about how to use `R`.

9,211 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
20 votes
0 answers
2k views

Implementation of CoVaR (a systemic risk measure) in R

I'm trying to estimate CoVaR using bivariate DCC GARCH in R. The concept of CoVaR is the dependence adjusted of VaR, which was first introduced by Adrian and Brunnermeier (2011). However, this ...
drawar's user avatar
  • 275
15 votes
1 answer
4k views

Interpreting and reporting gamm4 result

I am new to generalized additive models (GAMs), and most of my knowledge comes from this document. Now I am using a generalized additive model with random effects to model some data, where I want to ...
nan's user avatar
  • 1,135
14 votes
1 answer
3k views

How to generate 2 correlated Beta random variables

I was wondering if it might be possible to generate 2 correlated $Beta$ random variables? In other words, I want to generate two Beta random variables which can be said to have come from two Beta ...
rnorouzian's user avatar
  • 4,036
14 votes
0 answers
2k views

Negative deviance explained by GAM with betareg in R

I am fitting the following model in "mgcv" package in R using option family=betar to predict a percentage cover response variable (...
jatalah's user avatar
  • 483
12 votes
0 answers
5k views

How to use formative indicators in covariance-based SEM with lavaan?

I'm trying to build a covariance-based structural equation model (SEM) using both reflective and formative specifications of latent variables. I use the sem ...
jhg's user avatar
  • 325
11 votes
0 answers
3k views

Varying dispersion parameter (=dispformula) in glmmTMB in R to account for heteroscedasticity that originates from one predictor

I struggle with understanding the dispersion model and dispersion parameter of glmmTMB , and could not find answers anywhere. I constructed a GLMM using ...
eab's user avatar
  • 111
11 votes
1 answer
5k views

Generalized additive model: choosing between cubic and thin-plate splines

I am using the gam function (from the mgcv package) to model a continuous response (a soil nutrient) in relation to a continuous ...
michael's user avatar
  • 241
11 votes
1 answer
3k views

How to test for the difference in skewness of two samples?

I have two samples. From looking at their densities, one appears symmetrical and the other from some right-tailed distribution. I would like to test that the two do not have the same skewness (...
Tal Galili's user avatar
  • 21.7k
11 votes
2 answers
687 views

Hypergeometric: how do I construct a credibility interval around K (population successes) in R?

I have a problem for which I believe I should use the hypergeometric distribution, but I can't figure out how to do it in R. Say I have a bag of marbles with known number ($N$) of marbles, but the ...
nsheff's user avatar
  • 211
10 votes
0 answers
2k views

"weight" input in glm.nb function in R. How exactly does the weight affect the likelihood?

I would like to understand how the weight argument of glm.nb is affecting the likelihood function. I understand that glm.nb find ...
FairyOnIce's user avatar
10 votes
2 answers
2k views

Random Forest: Class specific feature importance

I'm using the bigrf R-package to analyse a dataset with ca. 50.000 observations x 120 variables, classified into two groups. After growing a forest of 1000 trees, ...
Misconstruction's user avatar
9 votes
1 answer
3k views

Error “system is computationally singular” when running cox.zph for a Cox Model

I have built an extended Cox Model in R, with time-dependent covariates, as described in this R vignette. I have built the model by running the following: ...
Mateus's user avatar
  • 91
9 votes
0 answers
11k views

Singular fit with simplest random structure in lmer (lme4), is a Bayesian approach the only option?

I'm running a mixed model with the lmer function from the lme4 package in R and ran into some issues with singular fits. I get the warning message 'singular fit', ...
Urs's user avatar
  • 91
9 votes
1 answer
2k views

How to estimate random-effects for new subjects for predictions (example in GNU R's lme4)

I'm wondering how to make predictions for new subjects from a fitted mixed-effects model (in a frequentist framework). Specifically, we have multiple observations on a set of subjects to which we can ...
Simon's user avatar
  • 191
9 votes
0 answers
754 views

The Regularization Path for Smoothing Splines

I've got a potentially interesting question. Does anyone know if R already has a package for calculating the entire regularization path of the smoothing spline? That is, for: $$\hat{f}_{\lambda}=...
Nick Thieme's user avatar
  • 1,274
9 votes
0 answers
2k views

When and why do I have to use "trait" for multinomial multilevel models with MCMCglmm in R?

I want to estimate a multilevel multinomial logit model but I am struggling with the terminology and notation used by the R-package MCMCglmm. There is documentation ...
non-numeric_argument's user avatar
9 votes
0 answers
713 views

Errors-in-Variables model for logistic regression

Simple question: I am familiar (though don't have tons of experience) with errors-in-variables regression. From what I have seen, this mostly is used with continuous outcomes in a linear model. A) Is ...
robin.datadrivers's user avatar
9 votes
0 answers
4k views

Appropriate negative eigenvalue correction for PCoA of genetic distances

I am trying to find the best way to represent genetic distances in a plane so that they may use them as response variables in canonical redundancy analysis (using ...
Xavier GB's user avatar
  • 126
9 votes
0 answers
2k views

Get canonical loadings (i.e. scores) from weights in r package PMA

I want to perform regularized canonical correlation between two matrices with more variables than observations (same subjects), one of which is very large (~18000 columns). The only r package that ...
Alice's user avatar
  • 895
9 votes
0 answers
162 views

Territories from observations

I have a number of animal observations, and want to deduce the number of territories (i.e. the number of individual animals) from this. More formally, the problem can be stated as follows: Each ...
MvG's user avatar
  • 500
9 votes
0 answers
6k views

Getting the bootstrap-validated AUC in R

In a paper by Faraklas et al, the researchers create a Necrotizing Soft-Tissue Infection Mortality Risk Calculator. They use logistic regression to create a model with mortality from necrotizing soft-...
oort's user avatar
  • 1,023
9 votes
1 answer
4k views

How probabilities are calculated for SVM model?

I would like to know, how probabilities are calculated in support vector machine. I have used Iris data set and here is my decision values for three "SupportVectorMachine" (please find the PMML below ...
Ramkumar's user avatar
  • 191
8 votes
0 answers
700 views

Are there any General Proofs on Genetic Algorithms?

Are there any general proofs or theorems relating to "genetic algorithms"? I have been reading about a theorem in math called the "Schema Theorem" - this theorem is one of the ...
stats_noob's user avatar
8 votes
1 answer
217 views

How to test the increase of proportions

Let say I've a contigency table as : score <=2 [3-4] >=5 no_event 248 796 288 event 71 419 285 I computed the ...
Nicolas Rosewick's user avatar
8 votes
0 answers
884 views

"Hierarchical" Random forests?

Background I am using Random Forest to classify ~900 objects based on a large number (> 80) predictors. I split these 70:30 for training and testing. The overall model does fairly well, giving an ...
EcologyTom's user avatar
8 votes
0 answers
351 views

How the Error() term in aov() decides what goes in which stratum?

I am trying to understand how the principles of nested anova in R, but I am having extreme difficulty with the error term. Imagining the simplest case. I measured plant growth in two places, A and B. ...
JMenezes's user avatar
  • 539
8 votes
0 answers
1k views

When and How to Scale Numeric Interaction Variables in Machine Learning Model

I found one similar question on cross validated, but it was unanswered; my apologies if this has been answered. I'm experimenting with feature interaction in a regression model I'm working on in R. My ...
TaylorV's user avatar
  • 203
8 votes
0 answers
405 views

when can I substitute an inverse with a pseudo-inverse in an estimator

Short Version: can I substitute the Moore-Penrose generalized inverse of a matrix (R function ginv()) for a matrix inverse (R function ...
gfgm's user avatar
  • 390
8 votes
0 answers
637 views

How good is an optimal design (DOE)?

I am looking at an experiment with 5 factors (4 numeric and one nominal) with three levels for each numeric and 2 levels for the nominal. Instead of the 162 runs, I am interested in a small design (30 ...
B_Miner's user avatar
  • 8,790
8 votes
0 answers
1k views

Interpretation of glmmPQL() spatial autocorrelation output

I am modeling binominal data with random effects and spatial autocorrelation using MASS::glmmPQL(). Plotting the residual semivariogram of a model fit without ...
pat-s's user avatar
  • 501
8 votes
0 answers
2k views

Will Tukey multiple comparison be the same for different types of Sum Of Squares of ANOVA for an unbalanced design

I am working on Two-Way ANOVA for an unbalanced design. Will Tukey multiple comparison be the same for different types (I, II & III) of Sum Of Squares of ANOVA for an unbalanced design. I am ...
cheedep's user avatar
  • 81
8 votes
0 answers
2k views

How to deal with underdispersion with binomial data

I'm working with a pretty large dataset (n = 4,500) where 10% of my points (pixels in a GIS landscape) are 1s and the rest are 0s. The full model for my data looks something like this: ...
Alejandro's user avatar
8 votes
2 answers
931 views

Should I control for random effects of participant in an individual differences design?

I'm trying to analyse a survey study in which I'm interested in the way that individual differences between my participants influence how they respond to my stimuli. The stimuli are pieces of writing ...
Sean Murphy's user avatar
8 votes
0 answers
3k views

Frequency weights, rare events and logistic regression

I'm working on a model that requires me to look for predictors for a rare event (less than 0.5% of the total of my observations). My total sample is a significant part of the total population (50,000 ...
Edu's user avatar
  • 561
8 votes
0 answers
3k views

Hyper-prior for negative binomial in hierarchical model using JAGS/BUGS

Below I'm using a negative binomial because it is more flexible than a simple poisson model. The data are counts $y$ of events for 16 individuals $x$. There are 14 counts (i.e. counting periods) for ...
user12719's user avatar
  • 1,109
8 votes
0 answers
4k views

Confidence interval for the restricted mean in survival analysis

What is the recommended way of calculating confidence intervals for the restricted mean in survival analysis? Here are some example data, taken from the paper Chris Barker (2009), The Mean, Median, ...
Karl Ove Hufthammer's user avatar
8 votes
0 answers
3k views

How to simplify coxme survival models?

I have some questions about specifying a coxme (mixed-effects Cox proportional hazards) model in R and then simplifying it after reading the ...
David Gibbs's user avatar
8 votes
0 answers
634 views

Calculate goodness-of-fit (with deviance) to compare averaged models?

I need to compare the goodness of fit of several averaged logistic regression models by calculating the deviance explained. I'm using the MuMIn package in R to ...
Jennie Miller's user avatar
8 votes
0 answers
366 views

Numerical properties of the logistic growth model for non-linear regression

I am using the nls procedure in R to fit a logistic growth model. In their SSlogis function, José Pinheiro and Douglas Bates chose the formulation ...
Rob Hall's user avatar
  • 1,292
8 votes
0 answers
2k views

mixed effect model for method comparison of time series of paired measurements

A coworker and I are trying to analyze agreement between two measurement methods. I apologize in advance for needing some extra explanation due to the fact I'm an engineer whose statistics background ...
Ben Voigt's user avatar
  • 200
8 votes
1 answer
1k views

Using Google Causal Impact package to assess the significance of a planned intervention

I am using the Causal Impact package in R to infer the causal effect of an intervention in some data which are highly correlated and seasonal. Specifically, i got 17 days of hourly data, intervetion ...
Trelokoritso's user avatar
7 votes
0 answers
169 views

Copula entropy: calculation is borked?

I came across a pretty cool paper whose idea makes a lot of sense to me. Ma, Jian, and Zengqi Sun. "Mutual information is copula entropy." Tsinghua Science & Technology 16.1 (2011): 51-...
Dave's user avatar
  • 64.3k
7 votes
0 answers
2k views

Meaning of the weight argument in glmer and lmer

I have been looking into how to use the weight argument of glmer/lmer to represent "frequency" weights. I was ...
matteo's user avatar
  • 3,263
7 votes
0 answers
2k views

What are the differences between HC estimators and their small sample properties?

I am currently using R to run regression with the following code: ...
Brennan's user avatar
  • 468
7 votes
0 answers
538 views

Mixed models formulation (GAMM, GLS, nlme): from R to mathematical notation

I have just finalised the analysis of a dataset fitting Generalised additive mixed models (GAMMs) with mgcv package in R v3.3.0. But I am having trouble in writing my models into their correct ...
Luca T's user avatar
  • 111
7 votes
0 answers
3k views

Interpreting Negative Binomial Time-Series

I'm working with time-series data for someone else that counts events related to emergency departments over a 48-month period during which closures occurred and would like to investigate the effect of ...
slackline's user avatar
  • 276
7 votes
0 answers
1k views

Interpolation with radial basis functions (RBF) is failing for some reason

This is not a pure programming question. I am trying to understand what's going on when I try to use RBF with 5 centers. I am using R to exemplify, see below. My data set: ...
DeltaIV's user avatar
  • 18.1k
7 votes
0 answers
2k views

Faster computation of high-dimensional multivariate normal probabilities

My goal is to find a faster way to calculate something like mvtnorm::pmvnorm(upper = rep(1,100)) that is, the tail probability of multivariate normal distribution ...
Randel's user avatar
  • 6,731
7 votes
0 answers
646 views

Gaussian Process Optimization Package in R

Many Gaussian process packages are available in R. For example there is $\textbf{BACCO}$ that offers some calibration techniques, $\textbf{mlegp}$ and $\textbf{tgp}$ focusing on treed models and ...
Wis's user avatar
  • 2,194
7 votes
0 answers
1k views

Missing value imputation in huge dataset

I have a huge data (4M x 17) that has missing values. Two columns are categorical, rest all are numerical. Given the huge amount of data, running any imputation method runs forever. What should I do? ...
Sonu Mishra's user avatar

1
2 3 4 5
185