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

7,392 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
816 views

Regularized Linear Regression with specific parameter constraints in R

Using R, I can only find tools for performing L1 and/or L2 regularized linear regression (lars, glmnet) and tools for constrained linear regression (quadprog , or lsei {limSolve} , where the ...
4
votes
1answer
100 views

I have 12 items to get into a single rank order. Can I get this from having a few hundred people see a set of 10 of the possible pairs of items?

I attempted to run a study where people had to rank order 12 statements from best to worst. However, it was extremely messy and difficult for people to rank that many items. Now, my professor and I ...
4
votes
0answers
155 views

force tgp to use a zero mean GP prior

I'm using the tgp package in R for fully Bayesian Gaussian Process Regression, and it's great! I'm currently performing regression for experimental data coming from ...
4
votes
0answers
2k views

How to fit a regression for log-normal with gamlss

Since my original question was to R-code-specific I'm trying to rewrite it: I want to make a regression where my dependent variable y should follow a log-normal-...
4
votes
0answers
390 views

Comparing unevenly spaced time series

I have multiple sets of time series data. However, the spacing of observation times is not constant within a time series itself, nor is it consistent between different time series. For example, ...
4
votes
0answers
642 views

Stability of tuning parameters in repeated elastic-net and variable retrieval

I am working with data that has $p$ close to $n$, and a high degree of collinearity between predictors. The excellent Introduction to Statistical Learning and Elements of Statistical Learning led me ...
4
votes
1answer
587 views

Poisson regression on aggregated data with an interaction term

For me, Poisson regression has been a nice tool to estimate risk ratios (setting offset to log-number of group size) and rate ratios (setting offset to log-risktime). Recently I came across a ...
4
votes
0answers
288 views

Distinguish between distributions

I have the following data frame and want to know what distribution is consistent with it. ...
4
votes
0answers
645 views

Understanding calibrating probabilities using R

I am trying to understand R's calibration(package:caret) function. My main interest is binary classification. Calibration function is used for plotting true ...
4
votes
0answers
1k views

How to find marginal effect of restricted cubic spline

I'm trying to figure out how to find the marginal effect of an interaction term from a restricted cubic spline in a non-linear model. The post Nonlinear effect in an interaction term is a good start ...
4
votes
0answers
1k views

Spatial Autoregressive Poisson model in R

I am estimating a gravity model of migration on cross-sectional data. The Moran I statistic indicates a positive and significant spatial autocorrelation in the residuals of the non-spatial model, and ...
4
votes
0answers
246 views

Difference between hierarchical Bayes and random parameter/effects models?

From my limited understanding, the difference is mainly that hierarchical Bayes (HB) incorporates parameter distribution priors that will "constrain" the individual parameters to one side of the ...
4
votes
0answers
2k views

Specifying the priors for multivariate MCMCglmm mixed model in R (Poisson distribution)

I am trying to build a model using MCMCglmm. Ideally, I would use a negative binomial distribution for my response; however, this is not an option in MCMCglmm. I don't know of any open-source ...
4
votes
0answers
987 views

What is the main differences between choosing hexagonal grid and rectangular grid for SOM?

While I'd expect people to answer this question by saying 'depends on the distribution of data', but what are the thumb rules for deciding which grid to use (either hexagonal or rectangular) for ...
4
votes
0answers
347 views

Visualization of normality condition for t-test in R

I am working through the concept of the need for normality in the underlying population when performing a t-test. This is nicely expounded by @Glen_b here. The gist of the explanation, I think, is ...
4
votes
0answers
1k views

Which logistic model is appropriate for longitudinal data?

I have data in longitudinal or clustered format (please see the example below). My response variable is dichotomous. I want to examine which factors explains why a subject in the dataset gets Y=1. In ...
4
votes
0answers
2k views

VAR Stability - Lag Order Selection

I followed this excellent tutorial on the implementation of Granger causality: http://davegiles.blogspot.de/2011/04/testing-for-granger-causality.html and applied the method with an R script. My date ...
4
votes
0answers
328 views

Generalized logistic model, sometimes with a bump

I am trying to fit a generalized sigmoidal function with a bump which is a Gaussian kernel to some data. My model is of the form $y\sim f(t)+\epsilon$ where $f$ is the function: $$ f(t) = A + \frac{K}{...
4
votes
0answers
657 views

Power of a Interaction term in R

I have analysed a dataset with a linear regression model, including an interaction term between a binary variable and a continuous variable. The interaction was significant. Afterwards, I have fitted ...
4
votes
0answers
451 views

How to calculate uncertainty in bacterial growth rates (or in the slope of any local regression)?

I'm using a plate reader to measure optical density of different bacterial strains so I can compare their responses (growth rates and changes in them over time) to stress conditions. The growth curves ...
4
votes
0answers
2k views
4
votes
0answers
500 views

Comparing likelihoods from non-nested models

Short: I have a series of joint probabilities (likelihoods) for how likely sample $Q$ belongs to group $K$. I need to compute a p-value describing how "significant" the "top" group is compared to ...
4
votes
0answers
309 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
1k views

Testing significance of linear discriminants

I have run a discriminant analysis and would like to test the significance of each resulting discriminant function - i.e., does each discriminant function contribute to the separability of the groups? ...
4
votes
0answers
839 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
1answer
691 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
1k views

R - quadprog package for constrained Lasso (penalized) linear regression

What I am doing so far: I am doing a constraint linear regression with R's quadprog package, function solve.QP(). The ...
4
votes
0answers
307 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
627 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
404 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
130 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
705 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
2k 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
4k 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
384 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
483 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
208 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
1k 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
571 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
616 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
239 views

Is there a way to add covariates to centile GAM curves in R?

Using the package "mgcv" I fitted a GAM to demonstrate head circumference changes over the lifetime for data stemming from two different countries; ...
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

compare quasi poisson models

I have two models: ...
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
397 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
990 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
5k views

Clarification on interpreting Wald's test and Likelihood ratio tests

I am running multinomial logistic regression analysis on my data. The response variable is the number of calves produced each year (0,1, or 2). I am trying to evaluate the influence of the X ...
4
votes
0answers
1k views

Plot directed acyclic graph with scaled edge length

I am trying to design a network (more precisely a directed acyclic graph) with specific edge lengths. The data is on the form of an edge list, and for each edge, there is an associated length. It ...
4
votes
0answers
3k views

Comparing ROC-curves

I would like to find if there is a significant difference between two ROC-curves. I've found the roc.test in the pROC package. However, I cannot seem to find any information on how this test is ...

1
3 4
5
6 7
148