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

learn more… | top users | synonyms

0
votes
0answers
34 views

Multilevel (Hierarchical) Models - data set example

I am currently trying to find an example that will use a Miltilevel/Hierarchical Model. The data set I am currently looking at is student "success" in a post-test regarding STD education. The data has ...
1
vote
0answers
31 views

Restricting a set of predictions to a range of values of non-negative numbers

I am not even sure how to even phrase this question so if anyone could help that would be great. I am analyzing facebook activity and I wish to predict a particular activity (comments, for instance). ...
0
votes
0answers
3 views

3D Array value assignment ruins the structure of array [migrated]

Here is how to reproduce my problem. I want to create a 3D array > g=array(0,dim=c(3,31,31)) > dim(g) [1] 3 31 31 > dim(g[1,,]) [1] 31 31 This is x with ...
0
votes
1answer
30 views

JAGS Error when fitting Gamma GLM: Invalid parent values

I am trying to fit a Gamma GLM to my data.Here's my code: ...
1
vote
1answer
70 views

Interpretation differences between deterministic seasonality and deseasonalized data with X-13 SEATS

I am running X-13 SEATS on r for monthly data in six years of observations and I think I got a (sufficiently) reasonable fit for the ARIMA model, but the output also shows me that my original series ...
0
votes
2answers
73 views

Is there a remedy for removing autocorrelations from residuals of seasonally fitted ARIMA model?

I fitted a number of SARIMA models using R and chose the ARIMA(0,0,0)(3,1,0)[12] as the best fitted model to the univariate data with 180 points (periodicity=12). This model is chosen as the best ...
0
votes
0answers
29 views

Correlation operations in R

I need som help using correlation matrix in R. Let's assume I have simulated 10 year of forecasted rental income for a property. The simulation parametar is accumulated income growth and my R code ...
0
votes
0answers
13 views

Implementing PCA using Incremental approach [migrated]

I am trying to implement the algorithm proposed in the paper in Section (III) here in R. It uses incremental eigendecomposition and incremental SVD for calculating IPCA. Instead of working on images ...
1
vote
0answers
7 views

making replicate for fixed covariates from Generated samples from Poisson regression

I have a Poisson regression equation. $$ \mu_i= exp(\beta ^{_{0}}+\beta _1x_1i +\beta _2x_2i ), i=1,...,n $$ Say n=20. Covariates are chosen randomly from (0,1). And beta0=1, beta1=.01, beta2=.5. ...
0
votes
0answers
26 views

Logistic regression w/ categorical predictors, and all residuals must be nonnegative

Has anyone written a package for R that can do a logistic regression over categorical variables (like glm) but with the constraint, and I do realize this is weird, ...
2
votes
1answer
56 views

Nested mixed effects with lme4

I am trying to analyze data from an experiment using lme4. In the experiment, subjects saw either dark or bright versions of 50 stimuli (between-subjects; fixed effect "brightness"). All subjects saw ...
0
votes
1answer
30 views

How can I change the control group for my dummy variables in R? [closed]

I am using R to run a linear regression. I have a group of 3 dummy variables that represent 4 plots of land (labeled as group 1, 2, 3, and 4). I would like to set Group 4 as the control group when I ...
1
vote
1answer
25 views

Testing the sum of GARCH(1,1) parameters

How can I test that the sum of the $\alpha_1$ and $\beta_1$ parameters in a GARCH(1,1) model is significantly different from 1?
0
votes
0answers
10 views

Efficiently processing a large MxNx2 logistic regression, only interactions matter

I'm working with a large 3-way contingency table (roughly $180 \times 40 \times 2$) — both independent variables are categorical and the response is binary. One independent variable (X) ...
2
votes
1answer
60 views

Linear regression analysis examples

I am looking for examples where linear regression analysis is used in answering real problems. That is, from formulating real questions as a statistical question, validating assumptions so on to ...
1
vote
0answers
13 views

How can we retrieve the cross-validation estimate error from local regressions in R?

I've been retrieving the following cross-validation estimate errors for natural splines (as an example). ...
0
votes
0answers
24 views

attrition model using random forest

I am using random forest in R to predict attrition. In the training data set 70% of the customer attrited. Following are the questions 1) can I down sample the data set with 50-50 of both the ...
0
votes
0answers
18 views

Interpreting output with deviation (sum)coding

How do I interpret main and interaction effects with deviation coding? This is the output I generated for Code_IS_Condition (3 levels), ...
1
vote
1answer
45 views

glm output in R: analysis without coefficiencts

Generally, coeficients and their p values are focussed upon while assessing the regression output. However, there are other things mentioned. How can we analyze the output of glm without the ...
0
votes
0answers
10 views

Difference between binomial, binomial() and 'binomial' [migrated]

What is the difference between binomial, binomial() and 'binomial' when using glm. They are not identical, as can be see by following code: ...
0
votes
0answers
8 views

Different behaviour for local regression function [migrated]

I'm fairly new to R and am trying to build a function similar to this. I have hacked the code with the aim of running locpoly to fit a local polynomial with an ...
0
votes
1answer
30 views

Non-linear model fitting

I would like to fit a non-linear model that looks like the following: $V(g)=a*A(g)/(b*B(g)+c*C(g))$, where $g$ represents a gene, $a$, $b$ and $c$ are coefficients of $A(g)$, $B(g)$, $C(g)$, which ...
0
votes
0answers
41 views

How to fit discrete data that have mode 0 to a log-normal distribution?

I am trying to figure out how to fit a log-normal distribution to discrete data that have mode 0, in particular, without first removing the zeros. For example, paper citation data are said to be ...
0
votes
1answer
27 views

Defining grad in R's optim for MLE

I have a ML I want to maximize in R's function optim. I am currently using the method BFGS. The optim procedure is quite slow however, and I was hoping to speed up the process by specifying the ...
2
votes
1answer
42 views

Rejecting Null Too Frequently in Poisson GLMM (lme4, glmmPQL, glmmadmb)

While trying to determine power for a Poisson GLMM, I started by checking the probability of rejecting the null for a given parameter when the null is true (parameter is zero). I kept coming up with a ...
0
votes
0answers
27 views

Trying to fit single layer neural net with R's nls (nonlinear least squares) function

Working on building a neural network modeling frame using graph objects in R. I have a data set on passengers of the Titanic, modeling binary "survived" variable against continuous "fare" and "age" ...
0
votes
0answers
28 views

How to create a new variable with values from different variables if another variable equals a set value in R? [migrated]

I have a complicated question that I will try to simplify by simplifying my dataset. Say I have 5 variables: ...
1
vote
0answers
30 views

How do you do constrained non-linear least squares in R [migrated]

I am fitting a non-linear least squares model in R. I wish to minimize $(Y - f(Xb))^2$ where $f$ is a nonlinear monotone differentiable function, $X$ is a set of features and $b$ is the parameter ...
0
votes
0answers
17 views

How does non-linear least square in R do inference?

Looking for some validation of a conclusion I've made. I have a binary variable Y and a feature vector X. I want to build a classifier with the logistic regression model. In R, if I fit a binomial ...
0
votes
0answers
15 views

Strange predict() results from GLMMadmb after adding Zero Inflation

I am attempting to model abundance of a species based location groups and environmental parameters. I've encountered a problem with the predicted values from these models that is associated with ...
1
vote
2answers
35 views

Multiple regression/correlation analysis, large dataset:ways, tools [closed]

I've got a large "clean" dataset (800 MB), containing 210k rows and 320 columns. There is 2 discrete string-type columns, others are numeric. One of such numeric columns is selected as depended ...
0
votes
0answers
19 views

Formula for pooling variance components across imputations in mixed effects models?

I've had no luck with this question. I see here that someone has asked a very good question about combining confidence intervals. I haven't been able to find anything about even combining the ...
0
votes
1answer
31 views

How to quantify the difference of each value with respect to the median of a list of values

I have a list of 7 numbers in the range [0-1]. I have a median of all of them. I would like to quantify how much different each number is from the median. Probably it is a stupid question but how can ...
0
votes
1answer
31 views

Weighted censored regression

As continuation of this question I have a model with a continuous predictor and factors. I want the fit of the the model (especially the beta to the continuous predictor) to fit best when 2 factors ...
2
votes
2answers
107 views

Double integral, monte carlo estimation

Suppose I have pairs of random variables where $X_i$~$U[0,1]$ and $Y_i$~$U[0,1]$ and I want to estimate it $$\theta=\int_{0.5}^{1}\int_0^{0.5}e^{xy}xydxdy$$ but $\theta$ needs to have variance less ...
2
votes
1answer
37 views

Is one variable more correlated than another with a third, in R

I have taken three measures, A, B, and C, for each subject in an experiment, and subsequently measured the correlations between A and B (r1) and between A and C (r2). What statistical test is ...
0
votes
0answers
13 views

Testing time effects in GMM model in R (panel data)

I ran two GMM estimations in R, one with just individual effects, the other with both individual and time effects (i.e., "individual" vs "two-ways" effects in GMM estimation). Now I want to test the ...
0
votes
1answer
30 views

Repeated measures through time using mixed effects in R, plus post hoc tests

I have been trying to figure out how to do a fairly basic repeated measures analysis using linear mixed effects in R, and then analysing it using post-hoc tests. The problem is that I'm not sure ...
0
votes
0answers
23 views

Distribution of output from accuracy {forecast}?

I'm trying to work out a method for "online" or live model evaluation for models used in forecasting. One approach is to use the R package strucchange, but it ...
2
votes
2answers
129 views

R random vector generator

Create an R function generating ordered pairs x,y sampled from the two dimensional distribution whose pdf is of the form $f(x,y)=cxy$, where $0<x,y<1$, and $c$ is a constant to be ...
2
votes
4answers
114 views

Monte Carlo integration with imposed variance

Implement an estimator using Monte Carlo integration $$\theta=\int_0^1e^{-x^2}(1-x)dx$$ Estimate $\theta$ with variance lower than $0.0001$ and write the variance of estimator depending on ...
0
votes
1answer
31 views

Chi-Square transformation on a partially unknown matrix

This question is a follow up to Hellinger transformation with relative data. I want to chi-square-transform my species abundance table, which represents only a fraction of the total species table. I ...
1
vote
2answers
15 views

Network size limitations of `netlm` and `netlogit` from R's SNA package

I am trying to run netlogit on a network of about 60,000 nodes, and I would like to know if the SNA package's functions are designed to support such large ...
0
votes
0answers
11 views

Variable as a column name in data frame [migrated]

Is there any way to use string stored in variable as a column name in a new data frame? The expected result should be: ...
0
votes
0answers
23 views

glmer warning message in r

I'm running a glmer with the lme4 package in R. When I only include main effects in the model, it works just fine, but as soon ...
0
votes
0answers
41 views

Heatmap small p-values

I'm experiencing some difficulties trying to manage too small p-values derived from a Fisher test. In particular I have p-values like: 2.220000e-121, 1.260000e-26, 1.260000e-334, and so on. The ...
0
votes
1answer
43 views

95% confidence interval for p in R

I have to construct a 95% confidence interval using R, but I'm completely lost :( This is the assignment: In a random sample of 200 claims filed against and insurance company writing collision ...
0
votes
0answers
19 views

Cox-Ingersoll-Ross model

I have the following r-kode for the Vasicek model model parameters r0 <- 0.02 thetaQ <- 0.05 kappa <- 0.1 sigma <- 0.015 T0 <- 1 simulation ...
1
vote
1answer
50 views

What distribution is this? (and how to simulate a sample from it in R)

This is the information given: 10% of the population is colour blind. Let $X$ be the number of colour-blind people in a sample of 20. The distribution is $X \sim Poisson(20, 2)$ - is this correct? ...
0
votes
0answers
11 views

Recoding variables with a pattern in R [migrated]

I am a stata user learning R. I want to translate the following stata function to R. Basically what it does is to recode several variable with names with a pattern with a loop function. i have ...