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,281 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
19 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
  • 265
17 votes
0 answers
4k views

Gamma hurdle model for continuous response?

I am modelling invertebrate.biomass ~ habitat.type * calendar.day + habitat.type * calendar.day ^ 2, with a random intercept of ...
Tom Finch's user avatar
  • 271
14 votes
0 answers
3k views

Interpreting and reporting gamm4 result

I am new to gam, and most of my knowledge comes from this document http://www3.nd.edu/~mclark19/learn/GAMS.pdf. Now I am using generalized addictive model with random effects to model some data, where ...
nan's user avatar
  • 1,055
13 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
  • 463
12 votes
0 answers
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
  • 3,236
12 votes
0 answers
4k 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
  • 315
12 votes
0 answers
3k views

glmer in R: Significance estimates are not robust to order of data frame

I'm using a mixed effects model with logistic link function (using lme4 version 1.1-7 in R). However, I noticed that the estimates of significance for fixed effects change depending on the order of ...
Sean Roberts's user avatar
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
  • 20.8k
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
573 views

How to judge whether to model a time series additively or multiplicatively?

I don't know how to to identify whether my time series is additive or multiplicative using decompose() command in R. It is a monthly time series.
Karima Touati's user avatar
9 votes
0 answers
5k views

gam: choosing between cubic and thin-plate splines

I am using gam (mgcv) to model a continuous response (a soil nutrient) in relation to a continuous predictor plus categorical predictors plus site random effects (modest number of sites) with: ...
michael's user avatar
  • 221
9 votes
0 answers
730 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,234
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
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
9 votes
0 answers
1k 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
  • 885
9 votes
0 answers
3k views

Interpretation of crossed random effect interactions in lme4

I'm considering a model in lme4 in which I am estimating random effects for two crossed factors, very similar to the Machines example in Bates' 2010 draft book (http://lme4.r-forge.r-project.org/lMMwR/...
Alyssa's user avatar
  • 91
9 votes
0 answers
154 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,013
9 votes
1 answer
3k 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
9 votes
1 answer
641 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
  • 191
8 votes
1 answer
169 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
2 answers
470 views

Confidence Intervals for the Parameters of a Logistic Growth Curve

I'm using the growthcurver library to estimate the parameters from some bacterial growth curves. It fits a logistic equation of the following form: This returns ...
Fomite's user avatar
  • 21.9k
8 votes
0 answers
10k 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
  • 81
8 votes
0 answers
307 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
  • 447
8 votes
0 answers
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
  • 181
8 votes
0 answers
368 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
609 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
  • 7,990
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
  • 491
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
0 answers
3k 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
  • 116
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,079
8 votes
0 answers
618 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
354 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
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
442 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
  • 7,142
7 votes
0 answers
139 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
  • 50.8k
7 votes
1 answer
2k 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
  • 71
7 votes
0 answers
1k 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
  • 458
7 votes
0 answers
743 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
7 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. ...
TaylorV's user avatar
  • 193
7 votes
0 answers
501 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
2k 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
  • 16.9k
7 votes
0 answers
582 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,144
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
7 votes
0 answers
660 views

Spinograms vs. conditional densityplots

I have a binary response variable (hail) and multiple continuous predictor variables. My aim is to understand the linear/non-linear relationship of the predictors to the response to be able to justify ...
pat-s's user avatar
  • 491
7 votes
0 answers
1k views

How should I include age in this mixed-effects model?

I've got repeated measures of hearing thresholds for a set of patients who each have a different inner ear measurement. This data is unbalanced, there are a varied number of measurements at varied ...
Mustafa Ascha's user avatar
7 votes
0 answers
900 views

Intepreting p values from R mediate() output

In the output below, the ACME p value shows that it is significant. But the p-value for Prop. Mediated Average is >10%. I thought Prop. Mediate is the proportion of the total effect mediated by the ...
condorcet-bach's user avatar

1
2 3 4 5
186