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`.

6,501 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
266 views

How do random data eigenvalues change, as random variables are added?

I am using parallel analysis (Horn 1965) to determine how many principal components I can extract from my data. I can add more variables to my dataset, but I cannot add more cases (I know, that's ...
4
votes
0answers
687 views

Coefficients of dummy variables in multiple regression

I am struggling with interpreting coefficients from a multiple regression analysis with multiple categorical (dummy) variables. I am running a linear mixed model with biodiversity (...
4
votes
0answers
240 views

4 specific questions about Logistic Regression with Categorical Predictors in R

I'm attempting logistic regression in R for a survey for 613 students. I'm looking to see if there is an association between my Dependent Variable (called 'BinaryShelter', coded as 0 or 1, signifying ...
4
votes
1answer
570 views

Need to extrapolate missing monthly data from annual data; the monthly/seasonal index is reasonably well-known

I have a revenue dataset for various businesses. For about half of those businesses, monthly data is available. For the other half, only annual revenue data is present. I know the seasonality of the ...
4
votes
0answers
485 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 ...
4
votes
0answers
302 views

Compare sample means of normal distribution with autocorrelation issues

Please forgive me if this is a naive question, but I haven't been able to find an answer in my stats books or online. I'm working on a fish tracking dataset that consists of detections of tagged fish ...
4
votes
0answers
564 views

How to fit an exponential equation of the form $Y = A + Be^{CX}$ to data

I need some assistance with a nonlinear adjust. I am trying to make a mathematical model that describes the rate of silicic acid escaping from an underwater sediment. For theoretical reasons, the ...
4
votes
0answers
381 views

Sampling from Wishart distributions with scalar degrees of freedom $(\upsilon>p-1)$

Let $\upsilon$ be the degrees of freedom of a Wishart distribution and $p$ the dimensions of its scale matrix. If the degrees of freedom is a scalar, then its range is: $$ \upsilon > p−1 $$ and ...
4
votes
0answers
114 views

R HoltWinters - Odd dip in predictions

So, I have this time series that tracks the daily number of applications to a graduate program. Each application period is 64 days - so for each period, you start at zero and it goes up until the ...
4
votes
0answers
671 views

Quasipoisson or negative binomial glmm with differing dispersion by group

I have a set of count data, which look something like this: ...
4
votes
0answers
1k views

How to use lagged dependent variables (panel data) in practice?

Working with a panel data set with a daily time series structure I was told to include a lagged dependent variable. The dependent variable is daily electricity consumption of a medium size sample (>...
4
votes
0answers
3k views

Box cox for mixed models in R

Consider a mixed model generated using the lme function in R. How can I consider the Box-cox transformations of this model in R? I have seen similar questions being asked before but they did not give ...
4
votes
0answers
340 views

How to model a power function ($y = ax^b$) with two exponents in two regions using R and nls

I have been unsuccessfully trying to model a relationship between two measured variables described by two different power functions, on either side of a threshold. My question is how to best estimate ...
4
votes
0answers
415 views

What state-space representation of VARMA is commonly used for fitting

What state-space representation of VARMA is commonly used for fitting? Is Kalman filter + MLE approach used for fitting VARMA model as a common practice? Does the choice of which state-space ...
4
votes
0answers
196 views

Student classification with Multinomial Logit

I’m analyzing student performance data. In my dataset each row corresponds to a student and each column contains several performance metrics (continuous) and the student type (categorical, 4 types). ...
4
votes
0answers
974 views

How can I evaluate spatial autocorrelation in a binomial GLMM?

Following Dormann et al 2007 Ecography, I have employed a GLMM approach in R to account for spatial autocorrelation in a binomial regression model (logistic regression) that does not have random terms....
4
votes
0answers
535 views

How to estimate the percent of the variation of a time series explained by another time series (non-stationary)?

I've been learning about time series analysis because I want to understand how much groundwater level changes in an aquifer affect land subsidence (land sinking). I have two time series: (1) ...
4
votes
0answers
529 views

chi-squared test vs fisher's test vs … => highly unbalanced length frequency data

I would like to statistically verify if two distributions are identical. Basically, the first distribution is a length frequency distribution from a large population ("population"). The second is the ...
4
votes
0answers
2k views

VAR model for price forecasting in multiple time-series context. How to get “real figures” as forecasts?

Sorry for the rather long introduction, but since I was (legitimately) critizised for not explaining my cause and questions enough, I will do so now. I would like to conduct a (price)-forecast based ...
4
votes
0answers
2k views

How to best approach ANOVA with multiple response variables that might be correlated and Bonferroni Correction

I need some help verifying a simple analysis. I have completed a simple two factor experiment of more or less equal sample sizes. Let's assume for the case of this question that the sample sizes are ...
4
votes
0answers
366 views

Why do my boostrapped CI's (using boot.ci in R) not include the point estimate?

I'm interested in estimating an average treatment effect $$ \operatorname{ATE}\left(A', A''\right) = \mathbb{E}\left( Y\ |\ A'' \right) - \mathbb{E}\left( Y\ |\ A' \right) $$ with a generalized ...
4
votes
0answers
2k views

R plm strange error when using pgmm

I have a data.frame that looks like this: ...
4
votes
0answers
949 views

How to deal with unequal sample sizes while fully embrace a dataset?

Imagine the situation: Mythical Seafolk use holes in the seabed as their burrows. Each hole has two parameters - diameter and depth. Majority of holes are unoccupied due to their surplus (n = 235). ...
4
votes
0answers
1k views

How to calculate standard errors of a non-linear model prediction?

I'm trying to understand how to show the prediction error of a model fit in R using the non-linear least squares function nls. Although there is an argument ...
4
votes
0answers
787 views

Compute Shannon entropy between every row of a large, sparse matrix

I have a sparse, binary matrix of user (rows) and items (columns). Each element of this matrix is either 0 or 1: ...
4
votes
0answers
422 views

How to fit log-linear poisson autoregressive mixed model?

I have time-series count data $N_{i,j}$ (population sizes in site $i$ and year $j$) and I want to correlate year-to-year changes with the environmental conditions $x_{i,j}$. For this, I want to fit ...
4
votes
0answers
1k views

ARIMAX for modelling daily sales

I am trying to model daily sales for a take out restaurant. They are only open on business days - no holidays or weekends - as their primary clients are office workers on their lunch breaks. Below is ...
4
votes
0answers
4k views

Backward stepwise regression with cross validation in R

I would like to do model selection using backward stepwise procedure and cross validation. https://www.otexts.org/fpp/5/3 I have used stepAIC in ...
4
votes
0answers
273 views

Can I use weights generated by robust regression in a quasipoisson glm in R?

I have response variable count data that should be treated as quasipoisson or something similar. This data also contains outliers which are important to the dataset. I cannot find an r package that ...
4
votes
0answers
806 views

Simulation for power analysis for higher order repeated measures ANOVA

I am attempting to find a way to perform a power analysis for a higher order repeated measures ANOVA where all factors are within-subjects (i.e., there are no between-subjects factors). I have looked ...
4
votes
0answers
87 views

finding position by regression fit

I try to estimate an underfloor pipe position based on a temperature distribution on a surface of the floor. I know there is the pipe emitting a hot temperature all way along. I can measure a ...
4
votes
0answers
1k views

Negative Hessian matrix in R optim

I used the optim() function in R to find the min log likelihood, however the diagonal elements of the inverse of Hessian matrix turned out to be negative. ...
4
votes
0answers
115 views

What analyses do I need to run?

Long post. Question at the bottom. My data look likes this: It consists of the test set accuracies of a series of 50 models formed on training sets. Using random sampling of the raw observations, ...
4
votes
0answers
6k views

Nested random effects group size using lme (in nlme)

I'm wrestling with a question regarding random effects that I haven't been able to figure out with my regular resources. I am examining the effects of two treatments (heat and water) on plant biomass ...
4
votes
0answers
664 views

Path analysis, sample sizes, and alternative analysis

I am examining how English ivy affects the occurrence of a salamander species under cover objects (e.g., logs). Soil moisture is assumed to be the major factor that affect their occurrence. My ...
4
votes
0answers
351 views

On nonlinear regression, fits, and transformations

I am trying to fit a nonlinear regression model in R using nls(). I have a form of the equation I want to fit to: $$y = (a \times x_{1}^c +b \times x_{2}^d) (x_{3}^...
4
votes
0answers
2k views

Adjusted / marginal means estimation in linear mixed effect model in R / Stata

I am a new R user, having some difficulties validating/replicating results from Stata (which a colleague uses) in R. We are investigating the time (TIME<-c(1:7))...
4
votes
0answers
3k views

Weights argument in glmer() when predicting proportion data: why is it needed when all weights are around the same?

What do the weights argument in glmer refer to? I used sample sizes as weights with ...
4
votes
0answers
2k views

How to interpret output of CVlm() in R?

I am using 10 fold cross validation using the CVlm() function from the DAAG package. This is part of the result shown: ...
4
votes
0answers
884 views

How to write a mathematical equation for GLM model with gamma and gaussian distribution?

I am writing a paper and the following is a code that I wrote in R. The reason that I am struggling with this is because I tried hundreds of models with different variables and the following model ...
4
votes
0answers
607 views

Obtaining predicted probabilities that include multiple random effects from mixed effects model

I'm running a mixed effects logit model with a binary response variable. The data are cross-national survey data, over multiple waves (i.e., World Values Survey). As such, the random effects specified ...
4
votes
0answers
880 views

How to test stability/variability of statistic over time, using R

I have a long time series data (running several years). I have split the data into several series, each of 1 month duration. I then perform some custom calculations on each of the 'shortened' time ...
4
votes
0answers
8k views

Fitting a zero-inflated negative binomial regression with R

In this thread, I laid out a problem involving fitting a model that attempts to use minor league baseball statistics to predict success at the major league level (explained in full in the thread). ...
4
votes
0answers
4k 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-...
4
votes
0answers
179 views

Which variables are driving correlations within groups

I'm running an analysis on a few data sets that each typically have 100-200 cases measured across 120-160 variables - something similar to looking at gene expressions. Each variable is a non-centered ...
4
votes
0answers
2k views

SVM classifier (with soft-margin) implementation in R, gamma value and quadprog

I'm trying to implement a Support Vector Machine classifier in R and I have to solve the optimization problem using the quadprog R package which solves problems of the form : $$min_b \frac{1}{2} b^...
4
votes
0answers
828 views

Mixed-effect modeling with paired observations & bounded response variables

I am quite new in the field of mixed-effect modeling. For a beginner like me, I guess I combine several levels of complication in my analysis: paired observations & bounded response variables. I ...
4
votes
0answers
1k views

Mixed-effects model for a strongly unbalanced design

I am somehow unsure on the best option to analyze these data. Here is my study case: The response variable is a morphometric measure, one for each individual. During 10 years, say 2000-2009, people ...
4
votes
0answers
2k views

How to do a multiple regression with ARIMA using R?

I am analyzing some tree physiology data (transpiration) in relation to a number of environmental variables (many of which are predictors such as temperature, PAR and vapour pressure deficit). I ...
4
votes
0answers
1k views

Finite mixture models with bounded data

I am trying to fit a finite mixture model to a dependent variable which is bounded (practically) between -0.594 and 1 (theoretically, the latent variable is bounded between -Inf - 1). The data are ...