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 program in `R`.

learn more… | top users | synonyms

1
vote
1answer
57 views

how to use arima to do mean model

I am learning arima by this site: http://people.duke.edu/~rnau/411home.htm and I want to get the same result as following notes: ...
0
votes
1answer
18 views

How to test for Zero-Inflation in a dataset?

I have a dataset which seems to have alot of zeroes. I have already fitted a poisson regression model as well as a negative binomial model. I would like to fit zero-inflated and hurdle models as well. ...
0
votes
0answers
22 views

Drop1() and Summary() on lm object

I need to analyse unbalanced data through linear regression: modJuin=lm(TleafMax~TairMax*orientation, na.action="na.exclude", data=aJuin) "TairMax" is a ...
0
votes
0answers
16 views

Residuals plot from ripley K function on spatstat

I am a rookie on R and on spatstat package. I would like some help with the Kres function on spatstat. As is always wise to plot the residuals from any kind of ...
9
votes
4answers
407 views

Model building and selection using Hosmer et al. 2013. Applied Logistic Regression in R

This is my first post on StackExchange, but I have been using it as a resource for quite a while, I will do my best to use the appropriate format and make the appropriate edits. Also, this is a ...
3
votes
1answer
65 views

R: test normality of residuals of linear model - which residuals to use

I would like to do a Shapiro Wilk's W test and Kolmogorov-Smirnov test on the residuals of a linear model to check for normality. I was just wondering what residuals should be used for this - the raw ...
1
vote
0answers
30 views

Vector autoregression with interval lag terms in R?

I'd like to perform vector autoregression on a two variable system. I know that the signals $x$ and $y$ have a time lag of > 100 time points, and thus any fit with that many time lag parameters is ...
0
votes
1answer
49 views

Why did K means clustering do a poor job in R

I am trying to implement K means clustering in R, Here is what my data look like: ...
0
votes
0answers
14 views

How to check the convergence of a binary simulation process?

I conducted a simulation study using like Gibbs sampling by which a $1000 \times 10000$ binary data set was generated. Now I would check the convergence of this simulation process. Suppose the output ...
3
votes
0answers
30 views

Profile likelihood confidence intervals = (-Inf Inf) in a glmer {lme4_1.1-7}

I fitted a mixed logit model with crossed random effects in lme4_1.1-7::glmer (R version 3.1.1 / OS X 10.9.4 Mavericks). Had to simplify the maximal random-effect ...
0
votes
0answers
14 views

model selection through sparse group lasso

I am trying to get familiar with the package SGL. The reference is http://cran.r-project.org/web/packages/SGL/SGL.pdf. I typed the example in, and tried to get the coefficients of the fitted penalized ...
2
votes
0answers
40 views

Fitting a logistic curve to cumulative data using glm()

I'm trying to fit a logistic curve to cumulative data, derived from satellite imagery. Previously, I have point observation data which were either 0s or 1s. Os being 'forest' and 1s being ...
0
votes
0answers
31 views

Difference between tuneRF {randomForest} OOB error and Model OOB error

I have used tuneRF {randomForest} function to know best mtry and got OOB error is almost 19%, however when i run the model using randomForest am gettin OOB error 28%. I am running the model on same ...
2
votes
0answers
75 views

Simple Time Series Analysis

Suppose we have collected a set of data points $\{a_{t}\}$ at time $t = 1, 2, ..., t', ..., n$. Each data point consists of the following attributes: ...
0
votes
1answer
19 views

Probabilistic importance value for Caret linear SVM classifier

In a linear SVM model, inside caret I would like to get the variable importance after recursive feature elimination, so according to the documentation: ...
4
votes
2answers
91 views

How to perform residual analysis for binary/dichotomous independent predictors in linear regression?

I am performing the multiple linear regression below in R to predict returns on fund managed. reg <- lm(formula=RET~GRI+SAT+MBA+AGE+TEN, data=rawdata) Here ...
2
votes
1answer
48 views

Regression with t-distributed errors and MASS::rlm

I have some data that I'm fitting a multiple regression to, with the twist that the error distribution is t (with user-defined degrees of freedom) instead of Gaussian. I've been coding up my own ...
0
votes
0answers
14 views

R - Warnings when using cv.lm

I've tried to apply cv.lm function instead of my own script which performs K-Fold cross validation and though the results are matching the formulas and my own thing, I keep getting warnings when using ...
0
votes
1answer
47 views

In which order should factors be removed when performing model simplification (lmer)?

I am a bachelor student in biology and for a project work, I have a model with a design like this (A, B & C are fixed factors, D is random and nested in C): ...
0
votes
1answer
40 views

interpretation of gam model

I'm doing a gam model for the adherence of hypertensive participants in a cohort study . My response variable is hypertension (no and yes) and my explanatory is the month of the interview. My ...
0
votes
0answers
19 views

How to simulate a structural break time series? [migrated]

I want to know how to simulate the following structural break autoregressive time series: $\begin{cases} Y_t = 0.9Y_{t-1}+\epsilon_t & \text{for }1\le t< 50\\ Y_t = ...
0
votes
2answers
79 views

how to detect outliers from residual plot?

I have the following residual plot. Can I detect outliers from residual plot? I want to remove 200 outliers in my data set, but I do not know how should I do that in R ? residual plots: scatter ...
0
votes
0answers
49 views

Prediction interval using predict and NeweyWest in R

I have a basic linear regression model I fitted to a time series. Unfortunately I have to account for autocorrelation and heteroskedasicity in the model and I have done so with the NeweyWest function ...
1
vote
2answers
44 views

How to interpret a negative correlation of random effects in a mixed-effects model (in R)?

I've just gotten stuck in interpreting the output for a linear mixed effects model. My model includes Week as a time predictor, and scores on a depression scale as outcome. I have not worked with R ...
0
votes
3answers
19 views

Why the density plot of a vector with uniqe numbers is a normal distribution?

The density plot of vector that containing unique number is normal distribution with mean 1: For example: plot(density(rep(1,100))
0
votes
0answers
11 views

Altering a glm object's variance-covariance matrix in R [migrated]

I am using glm to model health care costs as a function of various demographic factors, using cluster-robust standard errors since my observations are clustered within hospitals (HOSPNUM). In ...
0
votes
0answers
51 views

Anyone use R or Python as statistical tool in industry? How to get coefficients of gradient booting models?

I tried gradient boosting models using both gbm in R and sklearn in Python. However, neither of them can provide the coefficients of the model. For gbm in R, it seems one can get the tree structure, ...
0
votes
0answers
17 views

R - randomForest - rfcv function - explanation in laymans terms

My name is Abhi and I am trying to teach myself data science by solving problems on the internet. In my current model I am using a random forest & the rfcv function to test the performance of the ...
0
votes
0answers
4 views

Using dates in R for Theil-Sen [migrated]

I am trying to use dates as my X variable in a Theil-Sen slope estimation and I am having difficulty using the R package zyp ...
1
vote
0answers
32 views
+50

time varying continuous covariate with one single binary outcome

Despite having only a single binary outcome for each ID, there are multiple correlated measurements for the same test for each ID at different timepoints. The individual ID´s are obviously ...
0
votes
1answer
18 views

Mixed logistic ridge regression

I would like to build a logistic regression model in which I will be looking for predictor variables having a significant effect on the breeding success of a raptor bird. The predictors in the ...
0
votes
1answer
48 views

R code to solve for probability of normal distributions?

I don't understand which R code I am supposed to be using to figure these problems out. I brief explanation of what the code is doing would be amazing. The problems below are two different ...
2
votes
1answer
33 views

1-Way ANOVA with single independent/repeated (within/between) factor

I want to perform an ANOVA on data with a single factor with three levels. The difficulty for me is that two of the levels are repeated measures (within subjects) and the third level is independent ...
-1
votes
0answers
13 views

why is this giving me an NaN [migrated]

Ok, my problem is that I'm trying to compute $(-1)^{1/3}$, but when i ask R to compute this an NaN occur. > (-1)^(1/3) [1] NaN I really don't know why? I'm using R 2.15. i want to compute ...
0
votes
0answers
30 views

Which R packages offer the foldid (or simliar) parameter for cross-validation of group lasso?

My situation: small sample size: 116 binary outcome variable long list of explanatory variables: 50 (both continuous and categorical) explanatory variables did not come from the top of my head; ...
1
vote
0answers
114 views

Writing a coordinate descent algorithm for elastic net in SAS

In order to run Lasso and elastic net multiple regressions on my company's SAS server (which doesn't support R), I've been working on a coordinate descent macro for performing least squares ...
2
votes
1answer
57 views

What is the lme4::lmer equivalent of a three-way repeated measures ANOVA?

My question is based on this response which showed which lme4::lmer model corresponds to a two-way repeated measures ANOVA: ...
0
votes
0answers
29 views

Categorical Data

I have a questionare. Questionare has six variables, suppose x1,x2,....,x6 and each variable has six questions. each questions has a response , strongly agree, agree, indifferent, disagree, strongly ...
3
votes
0answers
49 views

Trouble fitting mathematical model to data in R

I am trying to select the correct mathematical model for my standard curve. This data was collected from spectrophotometry. I am hoping to get a model to help me detect very small absorbance. ...
6
votes
2answers
201 views

How trustworthy are the confidence intervals for lmer objects through effects package?

Effects package provides a very fast and convenient way for plotting linear mixed effect model results obtained through lme4 ...
0
votes
0answers
16 views

Diagnostics for the analysis of variance model

I have problem with the diagnostic of the one way analysis of variance model (fitted in R). I've checked all the assumptions of the analysis of variance 1) "For each level of the within-subjects ...
0
votes
1answer
43 views

How to test main effects of categorical variables in a binary logistic regression including an interaction?

I measure two binary responses from each participant (ChoiceVA = V or A, AestheticOnly = 0 or 1). There are two experiments (between-participant). I want to test the following hypotheses: ...
1
vote
0answers
12 views

In R: Replace values of a row if missing with values of another row [migrated]

I am relatively new to R and probably the solution to this problem is rather simple. I have a dataframe that looks like this: ...
3
votes
1answer
99 views

How can I optimize coefficients of an arbitrary model?

This might be terribly easy but I'm probably lacking the keywords to search for. Assume the following (dummy) data: ...
0
votes
0answers
32 views

lmer with multiply imputed data

How can I get pooled random effects for lmer after multiple imputation? I am using mice to multiple impute a dataframe. And lme4 for a mixed model with random intercept and random slope. Pooling lmer ...
-1
votes
0answers
33 views

Density distribution of outcomes of 2 dice rolled [duplicate]

This question is related to: http://stackoverflow.com/questions/26153925/r-studio-a-histogram-with-a-bar-for-each-frequency-value Amongst the outcomes of 2 dice rolled, the chances of 2 are equal to ...
0
votes
0answers
8 views

How to not only compute predicted values but also standard errors [migrated]

I am trying to generate standard errors for predicted values. I do manage to generate the predicted values, however, do not get the standard errors. Instead, I consistently get the following error ...
1
vote
0answers
32 views

Weighted Kaplan-Meier Curve Log Rank Test

I need to compare two weighted KM curves created by using the svykm function from the survey package. I am unable to find any ...
1
vote
1answer
38 views

R - MLE of modified Champernowne density

I've come across an article (http://papers.ssrn.com/sol3/papers.cfm?abstract_id=704903), in which author wrote about maximum likelihood estimates of parameters in the so called modified Champernowne ...
0
votes
0answers
30 views

How do I use R code to solve for probability of normal distributions? [duplicate]

I don't understand which R code I am supposed to be using to figure these problems out. I brief explanation of what the code is doing would be amazing. The problems below are two different ...