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,542 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
2k views

Which gam.check() output is most reliable in mgcv R package?

I have been studying Simon Wood's excellent book to aid my understanding and analysis of GAMs to my data, in addition to looking at some application papers of mgcv. The gam.check() function outputs ...
4
votes
0answers
266 views

The method of knock-offs by Barber & Candes for variable selection and FDR control

The knock-off method is a recent approach to variable selection and FDR control presented in two papers to be found here https://statweb.stanford.edu/~candes/papers/FDR_regression.pdf and here https://...
4
votes
1answer
260 views

Custom metric for model selection in auto.arima

I'm using the auto.arima function of theforecast package. I would like to perform the model selection using a custom metric ...
4
votes
1answer
385 views

Mclust: Data frame order affects solution

I've come across some behavior in mclust::Mclust that I would not have expected, which is that the order of variables in the data passed to ...
4
votes
0answers
292 views

Samples size with sample proportion close to 0 or 1

For a future monitoring program on small water bodies we want to calculate the sample size. The bodies of water are so small that their number easily exceeds 100.000 in the monitoring area and ...
4
votes
0answers
1k views

Copula-based Value-at-risk in R

I'm working on a value-at-risk calculation using copulas on different stock market indices. I know how to fit the copula, but I can't figure out how to apply the VaR approach in the next step. The ...
4
votes
0answers
140 views

Choosing between two available packages for multinomial logit on panel data in R

There are two available packages for estimating multinomial logit models in R, namely mnlogit and mlogit. I am wondering whether someone who used both can share his experience. Which one is better / ...
4
votes
0answers
997 views

Beta regression in R (betareg) - parameter intepretation

In a simple model, x is a continuous (normally distributed) variable predicting y. Since y ...
4
votes
0answers
235 views

Modern approaches to nonlinear regression which are available in R

I would like to fit a complex nonlinear regression model: basically, I have a complex computer code which has an input vector $\mathbf{x}$, a vector of calibration parameters $\boldsymbol{\theta}$ and ...
4
votes
0answers
319 views

R bayesglm: Estimates depends on order of variable

I did a logistic regression with bayesglm from package arm. I got different results depending on the order of the variables in the model: ...
4
votes
0answers
432 views

Post hoc comparison in GAM models

I'm analysing some roe deer biological traits with a gam in mgcv. One of my variable is a factor with nine levels (i.e represents a combination of litter size and sex: M, F, FF, MF and so on) and my ...
4
votes
0answers
470 views

Quantile approximation using Cornish-Fisher expansion

I am trying to approximate a set of quantiles from the estimated mean, variance, skewness and kurtosis of a random variable with unknown distribution. I tried to apply the Cornish-Fisher expansion of ...
4
votes
0answers
68 views

GLMM for binomially distributed outcome, testing differential hypothesis

I am trying to find a way, to investigate differences between conditions in an experiment. The design is as follows: Depended Variable: Logical (answer is correct [correct accepted or correct ...
4
votes
1answer
339 views

Sampling from under/over-dispersed count data in R

I am currently working a some datasets with count data in R, in which the response is the number of activities of a given type that were performed in one day by a population. For each type, I build ...
4
votes
1answer
1k views

Surface Fit Using Tensor Product of B-Splines

I am trying to teach myself surface fitting with splines using tensor products. I am trying to construct a toy example but I can't seem to get my example to work. I will try to explain the best I can ....
4
votes
0answers
155 views

different coefficients and number of df for the same lambdas (glmnet)

Using the same lambda in lasso regression from glmnet package in R leads to different results. When I set a default number of lambdas to 100 my minimum lambda is 0.03196 and df=54. When I set it to ...
4
votes
1answer
212 views

Why the standard errors are different between SEM and ols regression

This is a mediation model with a categorical exogenous variable. I am trying to compare the results by running SEM and regression. The third step regression was conducted and I found the estimates ...
4
votes
2answers
314 views

Confidence intervals of bounded variable

Given 1000 observations that come from a distribution that is bounded between 0 and 1. How do you calculate correct 95% Confidence intervals when dealing with a bounded distribution? ...
4
votes
0answers
458 views

Cointegration in R and Eviews

I need to repeat in R results of a fully-modified OLS estimation that I got in Eviews. Here is the Eviews estimation (updated): My code in R using the cointReg ...
4
votes
0answers
1k views

Predict with stats::lm() versus lme4::lmer()

What are the difference between a linear mixed model with random slope and intercept and a linear model with an interaction effect? If I predict the effect of 1) the main effect and 2) the random ...
4
votes
0answers
706 views

Prediction intervals for HTS forecasting

So I have a lot of time series with a hierarchical structure, and need to produce forecast for each base series and its aggregates by the hierarchical structure. I have decided to produce forecast ...
4
votes
0answers
218 views

Quantile regression - power analysis

I need to put together a (likely simulation-based) power analysis of a quantile regression. The analysis should include changing effect size (increasing slope). In ...
4
votes
0answers
856 views

Mixed Anova in R

I am trying to do an anova anaysis in R. The experiment done had each subject tested in Method 1 and Method 2 as well a being in one of 4 different Levels (each subject in one group). The goal is to ...
4
votes
0answers
413 views

Competing risks with left-truncation and right-censoring

Reading a paper "Cause-Specific Cumulative Incidence Estimation and the Fine and Gray Model Under Both Left Truncation and Right Censoring" Geskus (2011). I'm trying to implement the method and was ...
4
votes
0answers
3k views

Interpretating IRF correctly

We have following Impulse Response Function: ...
4
votes
0answers
854 views

Shapley Value with incomplete information

I'm building an algorithm in R to calculate the Shapley Value for players in a collaborative game. However, I do not have an outcome value for all possible coalitions, partially because the number of ...
4
votes
1answer
60 views

Need some OLS model help

I need some help with calculating a OLS regression model. The model is $sales = b_{0} + quantity^{b_{1}}$, and the objective is to find the own-price elasticity calculated at the means, $\frac{\delta ...
4
votes
0answers
416 views

GLMM with time-series covariance and binary response variable?

I have a binary response variable that was measured at irregular time intervals for a number of individuals. I want to fit a GLMM that accounts for the time-series covariance within individuals. I ...
4
votes
0answers
1k views

How to properly use generalized method of moments (GMM) estimation with plm in R?

In the context of panel data analysis my key independent variable wage affects the response not immediately but rather over time. Therefore I would like to use some ...
4
votes
0answers
3k views

Does the Box Tidwell test for linearity of the logit require predictors to be in the range [0,1]?

Given a multinomial logistic regression model with 4 independent variables, 4 relevant interactions and a dependent variable with 3 categorical outcomes, I wanted to test for linearity of the logit. ...
4
votes
0answers
1k views

Expectation-Maximization with a MLE package in R

As a follow up to one answer of the topic Expectation-Maximization with a coin toss: One of the user posted an R-code with MLE example almost a year ago (and his last online time here was 3 months ago,...
4
votes
0answers
611 views

Including seasons and months into GLMM: should they be crossed or nested effects?

I have collected data from five consecutive fishing seasons (five factor levels). Each fishing season has five months within (five factor levels). Considering that I have a temporal correlation in my ...
4
votes
0answers
868 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 ...
4
votes
0answers
390 views

How to test the result of cSpade

I'm new working with sequences rules and I am little lost about what is the next step. I already generate the rules but I'm not sure how to test them in a new dataset, in order to verify them. Do I ...
4
votes
0answers
373 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 ...
4
votes
0answers
121 views

What metric to calculate correlation between average user ratings of products?

What's the best method to see if there's a strong correlation between two types of ratings on a product level (product $1, 2, \dots, n$) where each product has ratings of type '$a$' and '$b$'? For ...
4
votes
0answers
94 views

Post-Production Model Monitoring?

I am interested in model monitoring techniques. To be clear, for production of a statistical model, let's say GLM, with a set of covariates (continuous). The model will go into production (live ...
4
votes
0answers
4k views

Zero-inflated model: non-finite value supplied by optim

So I have the following model predicting the presence of an animal on a certain spot. As a time unit quarter is initially used, but for one of the species of animals there is some (little) interesting ...
4
votes
0answers
525 views

Multilevel meta-analysis with non-independent effect sizes: correct model?

I'm conducting a meta-analysis on standardised mean difference scores. Some studies provide multiple effect sizes, thereby violating the assumption of independence. An example is given below (all ...
4
votes
0answers
9k views

Splitting data for train/test for time series

A week ago or so I was at a conference. Long story short, I ran into a friend who is quite good at machine learning so I asked them a question about why I might be getting what I think is poor fit on ...
4
votes
1answer
447 views

Changing sensitivity (cval) in tsoutliers resulting in unexpected results

I am using the excellent tsoutliers R package to detect outliers (additive outliers, temporary changes etc.), but the cval ...
4
votes
0answers
98 views

Markov Chain Monte Carlo (MCMC): How many samples are needed to get a uniform sample?

I am interested in a general answer although my question is rooted in a specific document. I am using the R package "hitandrun": https://cran.r-project.org/web/packages/hitandrun/hitandrun.pdf On ...
4
votes
0answers
1k views

Multivariate regression in Tensorflow where dependent variables also depend on each other

Dear Stackoverflow community, I would like to understand how to implement a multivariate regression in Tensorflow, where all the dependent variables yn depend on both input variables xn as well as ...
4
votes
0answers
4k views

How to interpret lsmeans output for my lmer model?

I've defined an lmer model in R with 2 fixed effects, 2 random intercepts and a random slope: ...
4
votes
0answers
200 views

Numerical integration of a function of an empirical CDF

I have the following equation $y = f(x)$ and I want to invert $f(\cdot)$ to find $x$ numerically. Because the function $f(\cdot)$ is quite complex I will solve $y - f(x) = 0$ instead, using the ...
4
votes
0answers
284 views

Decomposition of SARIMA models

I use R for time series analysis. I would like to evaluate decomposition algorithms. decompose and stl from "stats" package lead ...
4
votes
0answers
528 views

Identical mixed models in SPSS and R nlme, with different degrees of freedom. Which to trust and why?

I am analyzing a multilevel dataset with an AR(1) error structure and random intercept and slope. I fit what I believe is the exact same model in SPSS and R- my coefficients and standard errors are ...
4
votes
0answers
5k views

How to validate a Poisson GLMM model?

I’m using the glmer function from the lme4 package in R to model species richness adjacent ...
4
votes
0answers
1k views

Understanding Kernel Ridge Regression and How It Works (and Implementing it in R)

I am trying to understand how KRR works for drug-protein-interaction and many aspects of it seem very confusing. Supposing I have a data set as follows of Drug-Protein interactions; values show how ...
4
votes
0answers
2k views

How to fit a mixed effect model to a left skewed continuous response

Does anyone have any suggestions (short of transforming my data) on how to fit a mixed effect model to a continuous response variable that is left-skewed? Other words, what probability density ...