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,519 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
2k 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: ...
4
votes
1answer
768 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
212 views

Ensemble learning with time-varying covariates and effects

We are interested in replicating several duration studies in the literature using ensemble learning methods. After some experimentation, we opted for random survival forests (Ishwaran et al. 2008) for ...
4
votes
0answers
135 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
0answers
378 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
929 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
551 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
3k views

Interpretating IRF correctly

We have following Impulse Response Function: ...
4
votes
0answers
750 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
0answers
1k 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 ...
4
votes
1answer
58 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
929 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
999 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
415 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
652 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
375 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
301 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
112 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
76 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
3k 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
469 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
1answer
934 views

Identifying lagged effects / Distributed Lag Model

I would like to create a linear distributed lag model in order to do some forecast and also being able to interpret the results. Unfortunately I'm a bit confused with the process I should follow....
4
votes
0answers
7k 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
0answers
341 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 ...
4
votes
0answers
1k 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 ...
4
votes
0answers
356 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
95 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
3k 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
161 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
228 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
469 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
4k 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
812 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
1answer
96 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
145 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
1k 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
339 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
1answer
400 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
246 views

Distinguish between distributions

(Sorry in advance for my bad English.) I have the following data frame and want to know what distribution is consistent with it. ...
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
913 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
237 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
790 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
313 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
1answer
1k views

R: Regression, Two-stage Least Squares

I need to perform manually two-stage Least Squares(to illustrate its advantages), where the first stage is repeated median estimate and the second stage should be weighted least squares, where weights ...
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
580 views

Survival analysis with Frailty on large dataset

I am trying to fit a survival analysis in R with non-recurrent events and time-varying coefficients. The baseline distribution is exponential or Weibull and the ...
4
votes
0answers
607 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
435 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 ...