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
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
58 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
24 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
19 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
12 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
18 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
25 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
26 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
36 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
1answer
51 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
17 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
28 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
58 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
29 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
18 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
37 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
23 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
1answer
13 views

Multivariate regression or PCA to reduce response variables?

I hope the title is self-explanatory, but essentially I want to know which method is better: does it make sense to use a PCA to reduce a number of response Y variables and then conduct a univariate ...
0
votes
0answers
13 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
43 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
33 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
25 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
35 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
36 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
7 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 ...
1
vote
0answers
11 views

How to do multivariate outlier detection in mixed data with category?

I have a data table where the entries are in the following format. The first column is category, which represent the product category. I have 5 such categories. ...
0
votes
1answer
13 views

KS test - R, Minitab (and Systat)

I'm trying to figure out how Kolmogorov-Smirnov one-sample testing for normality is done in Minitab (or Systat, since the answers apparently match). If this is my data vector: ...
1
vote
0answers
37 views

Help with fitting a non-linear model in R using nlsList

I've done a lot of research so far on fitting a non-linear model in R, but I'm having trouble with it. I'm working with creating a ticket sales model that looks like: ...
0
votes
0answers
7 views

Obtain resulting table to plot graphics in R [migrated]

I'm new with R in QGIS, I could write a simple script, and I want to obtain the table resulting, the table wich R uses to create the plot graphics. How can I do that? This is the script: ...
0
votes
0answers
11 views

Increase plot graphic details in R [migrated]

I'm new with R in QGIS, I could write a simple script, and I want to increase the detail of the plot. How can I do that? This is the script: ...
0
votes
0answers
14 views

Confidence intervals on 'cross plots'

I have a large set of data comprising triples of points (t, y1, y2). At each t, I have a distribution of y1 and y2 points, each of which is approximately normal. I would like to create a plot of y1 ...
1
vote
0answers
32 views

Different p-values between Wald Z and Wald Chisquare

I have used lme4 for mixed effects models of reaction times and accuracy rates. I could not use lmerTest because the type of model I was using are not yet implemented there (problem with predictors ...
0
votes
1answer
65 views
+50

R: Fitting a model with periodic, nonlinear and categorical components

Can anyone give me some advice on how to fit a model with linear (some categorical), non-linear and time series components in R? I don't want to use a non-parametric model like a Loess smooth or ...
-1
votes
0answers
21 views

Extract data from pivot table to data frame (i.e. “reverse the pivot”) [migrated]

I have the following data showing some numbers, broken down by year and month (the more recent happens to be first, but that's not a problem). Is there (in R) a way to easily "reverse the pivot ...
0
votes
1answer
27 views

k-means in R generates same number of clusters but different cluster label

Hi there I am running a k-means code in R with the same data and with the same number of clusters, in this case 3, but each time that I run the code, the cluster label changes, for example. In the ...
0
votes
0answers
12 views

Advanced R Programming Questions. Variable Names in Environments [migrated]

I wrote 2 functions to archive objects from R (with their names - that's really important for me) and, if an object is of class lm, to archive data used to conduct ...
4
votes
1answer
98 views

chi square test or Z test?

SO I have an outcome from a biological experiment, where I have counted the number of dead cells upon a mutation. For example, in once case - out of 120 cells we saw 16% of the dead cells, but our ...
1
vote
1answer
32 views

Cross-correlation in R – dealing with missing values

I have two time series. One is an environmental variable (n = 108) organized by year and month. The other is a biological variable, also organized by year and month, but I have no data for some months ...