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

0
votes
0answers
6 views

Survival Analysis in R with Grouped Data

I'm just getting started with survival analysis and I'm having trouble finding something in R that will do what I'm looking for. Most of the packages use survival objects that have an individual ...
0
votes
0answers
3 views

How can I estimate model predicted means (a.k.a. marginal means, lsmeans, or EM mean) from a GEE model fitted in R?

I am trying to obtain model-predicted means and CI's for a categorical predictor in a GEE model fitted with the geeglm function (geepack package). The model is fitted with no problem, but where I am ...
0
votes
0answers
17 views

lmlasso does not work for p>n

I am using the following example from the R manual: ...
0
votes
0answers
8 views

Introduce lag term in formula using dlnm package

I am using the dlnm package to build a finite distribute lag linear model. I intend on testing the model-fit based on various lag levels to assess which lag is ...
0
votes
1answer
28 views

clustering high dimentional data (p > n) in R

I have a situation where we have a number of quantitative features / variables (p) than the number of samples (n). My objective is to classify these samples into groups (may be hierarchical). I can ...
0
votes
0answers
6 views

Leave-one-subject-out cross validation in Caret

Hi Dear Colleagues, I wonder how to correctly setup a leave-one-subject-out cross validation (LOSO) for train() function in caret. Here is my example code: ...
0
votes
0answers
23 views

VIF in GLM model in R

Before running or building a model, ho can we check on the multicollinearity between different covariates in GLM model in R? I know that SAS Proc MIXED procedure gives a column for VIF which is very ...
0
votes
0answers
17 views

Problem when doing pre-whitening before ccf analysis

I have following R code which does not work when trying to pre-whiten other series by the model generated for the other series. -- Libraries; library(forecast); library(TSA); library(xts); -- Read ...
0
votes
0answers
5 views

boosting with ada package. How do I take the most probable answer from predict?

I trained classifier using ada. Now I executed: predict(adaDol,newdata=cords()) and received response: ...
0
votes
0answers
21 views

Sharing a Legend between two combined ggplots [migrated]

I'm currently trying to present two time series using ggplot2, both with very different scales, using two ggplots. I've combined the two separate ggplots, one on top of the other, using ...
0
votes
0answers
13 views

R: Package 'sphet' on spatial autoregressive models

I'm using the function gstslshet from the package sphet in R, but I'm wondering what the outcome is. Is it a model which can be ...
0
votes
0answers
19 views

Can we easily avoid the “maximum supported lag is 350 error” when using the ARIMA function in R? [migrated]

I am currently fitting a SARIMAX model to big data sets. Information is retrieved every 10 minutes, so I have a vector of size 52560 for a year of data. Considering it is representing electricity load ...
1
vote
1answer
24 views

Creating a cluster analysis on multiple variables

I am working on creating a cluster analysis for some very basic data in r for Windows [Version 6.1.76]. The groups themselves are countries and then I have 2 column with continuous numerical ...
1
vote
0answers
10 views

R Sales Modeling with Non-Replenishing Inventory

I'm working on modeling sales for tickets for a specific event over time. The issue that I'm having is that the inventory does not replenish, so I can't have my model predicting over what I actually ...
0
votes
1answer
48 views

hclust, R and Euclidean distances: weird stuff

I have a table of similarities expressed through cosines and am trying to do some cluster analysis in R, using hclust and ...
2
votes
1answer
13 views

conducting multi-level regression on ordinal DVs with imputed data in R

Do you know of an approach/package that facilitates mixed model regression of ordinal dependent variables on multiply imputed datasets in R? Ideally, the function takes: a list of multiply imputed ...
0
votes
1answer
11 views

Caret varImp for randomForest model

I'm having trouble understanding how the varImp function works for a randomForest model with the caret package. In the example ...
1
vote
0answers
16 views

How to generate survival data with time dependent covariates using R

I want to generate survival time from a Cox proportional hazards model that contains time dependent covariate. The model is $h(t|X_i) =h_0(t) \exp(\gamma X_i + \alpha m_{i}(t))$ where $X_i$ is ...
1
vote
1answer
25 views

Durbin Watson test statistic

I applied the DW test to my regression model in R and I got a DW test statistic of 1.78 and a p-value of 2.2e-16 = 0. Does this mean there is no autocorrelation between the residuals because the ...
1
vote
0answers
31 views

Low explained variance in Random Forest (R randomForest)

I am using randomForest in R for regression, I have many categorical predictors (all of them have the same 3 categories (0,1,2)) and I want to see which of them can predict the response (continuous). ...
1
vote
2answers
31 views

Prediction interval for a fitted log-normal distribution

What I am trying to do is to fit a log-normal distribution to a data-set, and then determine confidence and prediction intervals for the fitted distribution - not just for the mean and sd estimates. ...
0
votes
0answers
26 views

R. function hclust, euclidean distances and cosines

My data is a table of cosines and I want to analyze it with hclust, which works on squared Euclidean distances. shall I do: d <- dist(mydata, method = "euclidean") fit <- hclust(d, ...
0
votes
0answers
14 views

Conditional logistic regression model does not converge but logistic regression model does

I am running an analysis where I have 2500 cases and 2500 controls. The cases have disease A, and the controls do not. I am trying to see if having disease A increases the odds of various diseases. ...
0
votes
0answers
21 views

R² (squared) from a generalized linear mixed-effects models (GLMM) using a negative binomial distribution

I try to compute the marginal and conditional R² for a GLMM using a negative binomial distribution by following the procedure recommended by Nakagawa & Schielzeth (2013) . Unfortunately, the ...
0
votes
0answers
5 views

Boruta score goes to minus infinity

I'm running the Boruta algorithm with a $179\times 36$ predictor matrix and a numerical response. Most of the variables have a score going to -Inf. Should I ...
0
votes
0answers
3 views

How do I split my x-axis into multiple plots in ggplot? [migrated]

I have the following dataset: ...
1
vote
2answers
117 views

How to compare the outputs of two algorithms computing SVD?

For example we have 2 algorithms from R: SVD and irlba and I want to compare them int terms of speed,memory and precision. But I don't understand how to compare output of algorithms, they must be ...
0
votes
0answers
15 views

Transformation of the data

Which Transformation should i apply for the data which having 0's and large values? min value is - 0 and max value is - 2254 here we should not delete any cases from the data.
1
vote
1answer
13 views

Calculated breeding values using markers using animal model in R

Animal model (frequently used in animal science and sometime in human or plants) is mixed model with: $y$ = $X$$b$ + $Z$$u$ + $e$ y is observed values for any quantitative variable, $Xb$ is fixed ...
0
votes
0answers
21 views

Writing R code for first 84 days of a non leap year [migrated]

How do I set up a variable of length 84 that gives the correct month for the first 84 days of a non-leap year (using labels "jan","feb","march")?
0
votes
1answer
22 views

Interpreting CCF correlation in R

I am using ccf to find a correlation between 2 time series. I am getting a plot that looks like that: Note that I am mainly interested in correlation for the ...
1
vote
3answers
28 views

Can you set a minimum limit for the Y-intercept in R?

I have two sets of test scores I'm using to predict future performance, using multiple regression, and I noticed that the y-intercept is negative. This indicates that for a student who scores a zero ...
1
vote
1answer
55 views

How to capture & present lm model output from R

After running iterations of lm() in R, I am now stuck with which components of the model's output to present and how to present them. I know that the $R^{2}$ value, ...
0
votes
0answers
16 views

Dynamic pricing optimization of function in R

I'm working my way through a simple dynamic pricing model, and I'm having trouble figuring out how to optimize what I'm working on. I want to maximize $\Sigma_{t=1}^TR(D_t) - h_tI_t$ for the ...
0
votes
2answers
30 views

Count event using Poisson random variable

An event occurs with a mean of 15 times per hour and a standard deviation of 10 times/h. From the population a sample of 100 individuals is drawn. What is the probability that the sample mean will be ...
0
votes
1answer
19 views

Confusion between caret randomForest predict() results and reported model performance

This question seems related, but the consensus was that the issue had to do scaling the data, which I do prior to training, so I don't think that's the issue: Issue on prediction with FinalModel of ...
1
vote
1answer
18 views

R - Test for homogeneity of regression slopes results in singular model

I am trying to check the assumptions of a two-way ANCOVA. So in my model I have two factors (F1, F2) one dummy coded two level covariate (C) one dependent variable (D) In order to check the ...
0
votes
0answers
11 views

Meta-analysis in R with multiple probes of a microarray

Regarding a question posted here, I have the same problem and I can't figure out a solution. I started by doing my meta-analysis in PLINK, but I want the confidence intervals of the meta-analysis, ...
0
votes
0answers
16 views

center variable separately for each factor in linear mixed model?

I am working on a relatively simple mixed model where I have two continuous predictors with an interaction term and three sites. I am treating the two predictors as fixed effects and the site as ...
0
votes
0answers
22 views

'irr' R Package giving ICC values outside of 0 - 1

I ran a study looking at MEG (EEG with magnets) responses in the gamma-band (30-50Hz) range across multiple days. The following data is the timing of the initial response in that range (in seconds), ...
1
vote
0answers
38 views

Multivariate logit

I have n individuals with k possible financial products where they can put a % of their incomes. I need to predict for each individual the percentage of income that they allocate in each product. Is ...
1
vote
0answers
25 views

Power analysis for binomial data when sample sizes are different

I'm running an A/B test where I want to compare two different layout of a button and want to see if one layout lead to a higher Click-Through Rate with a certain statistical power. I want to use a ...
1
vote
0answers
25 views

Where can I find resources to learn about change-point analysis ?

Where can I find resources to learn about change-point analysis ? Hopefully, someone can advise me a textbook to read and it will cover both univariate change-point analysis and multivariate ...
1
vote
1answer
38 views

Model Formulae. correct model?

I'm trying to build the following model in R, however I'm quite confused about the model formulae to use to include an interaction (x1 and x2) $Y_{}=a+b*x_1+cx_2+d(x_1*x_2)$ this intuitive formula ...
0
votes
1answer
35 views

Generate data from a bivariate power-law distribution in R

I need to generate data from a random vector that follows a bivariate power-law: $$ f_{X,Y}(x,y) = \frac{C}{XY} \left(\frac{X}{X_0} \right)^{-\alpha} \left(\frac{Y}{Y_0} \right)^{-\beta} , $$ where ...
0
votes
0answers
45 views

Visualize process data

I have a dataset of order processing with 8 million rows with following columns: HistoryId - Identity column of the records ...
-2
votes
0answers
13 views

Error in eval(expr, envir, enclos) : object 'Case' not found in train( method=rpart) in caret package of R [on hold]

I am trying to fit my training data for Coursera Practical Machine Learning Quiz 2. ...
2
votes
1answer
31 views

How to plot a comparison of read counts in R

I have a bunch of genetic read counts for different several genes. Each gene is divided into two groups (0 and 1). What I want to do is make a vertical plot side by side of the 0 group and the 1 ...
0
votes
0answers
24 views

Arima model - multi step forecast

The following code shows a forecast of the next 24 hours of my electricity prices with two exogenous variables. My problem is, that I don't know how to build a forecast for the next 3 days or more ...
1
vote
1answer
57 views

Should a Poisson regression be carried out with only 3 data points?

I'm trying to test the relationship between the number of adults counted and the percentage heather cover over 3 areas. The data looks like this: ...