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

2
votes
1answer
3 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 ...
1
vote
0answers
8 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 Xi is ...
1
vote
1answer
19 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
8 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). ...
0
votes
2answers
19 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
16 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
12 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
15 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
3 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
109 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
12 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
20 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
27 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 ...
0
votes
1answer
39 views

How to capture & present lm model output from R [on hold]

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
15 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
16 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
16 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
10 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
21 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), ...
0
votes
0answers
21 views

Reference for manually fitting regression in R [on hold]

Anyone know a book, website, notes, course or anything that can use as a starting point to learn about fitting regressions manually in R? OK, the linear regression of the logistic regression might be ...
1
vote
0answers
37 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
34 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
35 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
21 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: ...
0
votes
0answers
27 views

Significance of varibles after stepwise regression

I did stepwise regression with my multiple regression model and using AIC as a measure of fit with the step function in R. Afterwards some variables that the ...
1
vote
0answers
17 views

Partition of sums of squares (ANOVA)

Can anyone explain the theory (or the formula) about computing Sum Sq (bold highligh below) related to regression items? The Wikipedia link gives an introduction on how to calculate the total, model, ...
0
votes
1answer
23 views

prop.test: correcting for large number of observations

This is not really a coding question but more of a statistical question. I'm doing a proportions test on multiple proportions for many subjects. For example, subject 1 will have multiple proportions ...
2
votes
1answer
36 views

VIsualizing the effect that only one predictor has on the outcome (R)

So I have performed a logistic regression on a data set with multiple predictors. I want to graphically represent the relationship between the outcome and only one of the predictors. What would be the ...
2
votes
1answer
13 views

Small number of points driving correlation

I am currently looking at trying to find high correlations in a series of data. I initially just thought I could check the correlation of the data and choose those with the highest correlation but ...
1
vote
0answers
21 views

How to test whether a distribution follows a power law?

I have the data of how many users post how many questions. For example, [UserCount, QuestionCount] [2, 100] [9, 10] [3, 80] ... ... it means each of the 2 users posts 100 ...
0
votes
0answers
10 views

How to calculate marginal effects for categorical covariates using mlogit in R

I am trying to use the mlogit package in R and have been following the vignette trying to figure out how to get the marginal effects for my data. The example ...
0
votes
0answers
16 views

R rpart classification tree error

I am trying to run a classification tree in R using the rpart package in R. I keep getting the following error: ...
1
vote
1answer
38 views

Multivariate model in lme() with independent random effect, similar to MCMCglmm

I would like to specify a multivariate model with lme with a random effect for group which is independent across variables. I found this post, which explains that ...
-1
votes
0answers
29 views

Robust regression in R with robust::lmRob

I am using the lmRob function in R to do my robust regression. In the R documentation of lmRob found here you can set the ...
-1
votes
0answers
23 views

Is this the proper way to create a simple linear time series model in R

I'm trying to create a simple ols model over time from a time series. Here's what I have cagr.lm.time <- lm(cagr.xts ~ time(cagr.xts)) Where cagr.xts is the ...
1
vote
0answers
23 views

Logistic regression with multi-class features in R

I'm working with a data set like the following: X = ...
1
vote
0answers
29 views

How to deal with “not applicable” values in categorical variables

My situation: small sample size: 116 binary outcome variable long list of explanatory variables: 44 explanatory variables did not come from the top of my head; their choice was based on the ...
1
vote
0answers
34 views

methods to perform feature selection in unsupervissed learning

What are the available methods/implementation in R/Python to discard/select unimportant/important features in data? My data does not have labels (unsupervised). The data has ~100 features with mixed ...
0
votes
0answers
6 views

gbm R multinomial vs bernoulli

I am using the gbm package to fit a binary variable using several attributes, some numeric and some categorical. Since the output varible was defined as factor I initially did ...