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
4 views

Caret and GBM: task 1 failed - “arguments imply differing number of rows: 0, 9902”

I'm trying to run a GBM with caret with the code below: ...
0
votes
0answers
2 views

Purpose of multiple models with fixed slope

I'm fairly ignorant when it comes to fitting models, and I'm having trouble grasping the point of fitting more than one line with the same slope. Is this generally used in a context with factors, ...
0
votes
0answers
15 views

Daily Time Series Analysis

I am trying to do time series analysis and am new to this field. I have daily count of an event from 2006-2009 and I want to fit a time series model to it. Here is the progress that I have made: ...
0
votes
0answers
10 views

Mechanics of converting success/failure values to logit in glm?

While I am reasonably comfortable with performing and interpreting the output from logistic regression using glm in R, I had a question about the mechanics of the calculation to better understand what ...
-3
votes
0answers
18 views
1
vote
0answers
7 views

Use lmer to test main effects and interaction

I have to solve a problem using a linear mixed model (lmer). Six subjects performed two tests, (test1, ...
1
vote
0answers
7 views

What is the test statistics used for a conditional inference regression tree?

In Hothorn et al, the test statistic is specified as $$ T_j(L_n, w) = vec(\sum w_i g_j(X_{ji}) h(Y_i, (Y_1,...,Y_n)^T))$$ What is the exact form of this test statistic with a continuous response and ...
2
votes
1answer
31 views

Finding how many times I need to perform an action before I have an x% chance of a specific outcome in r

Non-specific question: There is an action that can be performed that has multiple outcomes. Each outcome has a different probably, p, of occurring. How many times, n, do I need to do the action before ...
0
votes
0answers
17 views

Panel data - industry average calculation in R

I have panel data with many observations of companies' financial indicators that could be grouped by year and industry. What should I do if I need to adjust each observation by the yearly industry ...
0
votes
0answers
20 views

multiple linear regression analysis with continuous and categorical data result interpretation

I have data from gene expression arrays and I have clinical data associated with the samples used. I am using gene expression (discrete), age at diagnosis (discrete) and ethnicity (categorical) to ...
0
votes
0answers
10 views

Isolate 10% of observations based on conditions [migrated]

My data frame has a 10 columns and 100,000 rows, each row is an observation and the columns are data pertaining to each observation. One of the columns has the date of an observation in the Julian day ...
0
votes
0answers
25 views

Replicating SPSS factor analysis/PCA in R [on hold]

I am trying to replicate SPSS factor analysis/principal component analysis results in r using two previously suggested methods, but neither has succeeded. (What are the differences between Factor ...
0
votes
0answers
6 views

Specifying interaction term within nested factors in lmer [on hold]

I'm trying to understand how to include a nested term within an interaction effect in a mixed model ANOVA. Data: Factor A (Fixed) Factor B (Random) Factor C (Random) Factor D (Random) Model: ...
2
votes
2answers
32 views

Variance of slope

I have a bunch of data that I fit a linear regression to, and now I need to find the variance of my slope. Is there an analytical way to get this? If an example is necessary, consider this my data in ...
-2
votes
0answers
16 views

optimizing Average Run Length [migrated]

How can I code in R to solve for $p$ in $370=(1/p)(1/[1-(1-p)^L]),\ L=1,2,3,...$ and get the positive values of $p$ at different values of $L$ even when $p$ is at the right hand side of the equation. ...
3
votes
1answer
33 views

Getting an Excel file with many sheets into R [on hold]

I am importing data from an Excel file that contains 15 sheets. Each sheets represent a year in which there are observations on the same variables. Here is what I would like to do (elgantly) from R: ...
1
vote
0answers
18 views

Different results based on two target rotation approaches

I am trying to do some data analyses based on target rotation in R using two different approaches. Here is a small simulation in r. ...
2
votes
1answer
25 views

How to perform a simple smoothing forecast for next 12 months (using forecast package in R) [on hold]

I currently have timeseries data (of gold prices) and I am trying to use a simple smoothing forecast to estimate gold prices for the next 12 months. I am not sure what function to use to accomplish ...
0
votes
1answer
22 views

lmer syntax for a two-way model with one fixed and one random factor [on hold]

Please could anyone tell me if my R code is correct? I have a two-way model with one fixed factor, habitat, and one random factor, site. The code I am using is: ...
0
votes
1answer
22 views

Applying randomforest algorithm (fit) on new data without recomputing the fit [on hold]

I have a need to do realtime predictions for individual rows of data based on a previously computed randomForest algorithm. How can I run the "predict" command without recomputing "fit" on the entire ...
0
votes
1answer
26 views

Post hoc analysis for linear mixed model with nested effects

I'm having trouble in R with my Linear Mixed-Effects Model. I'm working with yeast in nectar. This is a part of my data just so you can see what is going on: For the condition sucrose, I have 4 ...
0
votes
0answers
23 views

How to interpret the coefficients from Dirichlet Regression?

I have a response Y, which consists out of 5 response variables which are proportions and for each observation, add up to 1. I'm tying to regress these with a set of independent variables. As I ...
0
votes
0answers
12 views

nnet function in R

I have 7 input variables,2 hidden neron and 1 output variable.the train sample are 50.I used nnet function in R to train my network but it returns 187-2-50 network with 526 weights means 187 inputs ...
0
votes
0answers
25 views

how to debug the error in R codes [on hold]

I used the 'neuralnet' package in R to train the network, but it gave me the error such as below: ...
0
votes
0answers
24 views

Are there peer-reviewed psychology or neuroscience journal articles that include the raw data (data set)? [on hold]

I am hoping to carry out a pedagogical analysis of a peer reviewed paper. This would be easier with the raw data its self, in additional to the results section of the paper.
0
votes
0answers
4 views

Implications of using fixed effects to account for hierarchical data structure

I am currently implementing a hidden Markov model in R, using the msm package. The data I am using are drawn from a cluster-randomized trial; i.e. there is a ...
0
votes
0answers
11 views

Generating markovian paths

given a 4 by 4 transition matrix P, I want to simulate m Markovian paths of length n I created this function can anyone tell me if this is is correct ? ...
0
votes
0answers
11 views

R - Combining and visualising spatial data [migrated]

I'm trying to combine some spatial data with a csv data frame then produce a visualisation of some features of the result using ggplot2. When I combine the data and then try to fortify the result so ...
0
votes
0answers
23 views

What is the use of as.numeric() in R? [migrated]

this is Ex.1 on Page 252 in Statistics and Data Analysis for Financial Engineering by Ruppert: This problem and the next use CRSP daily returns. First, get the data and plot the ACF in two ways: ...
2
votes
0answers
17 views

Can complete separation between a continuous predictor and a random effect cause failure to converge in a logit GLMM?

I’m running a logit mixed-effects model on binary data with a 2x2 within-subjects design, with subjects and items as crossed random effects, and the two independent variables deviation-contrast coded. ...
0
votes
1answer
33 views

Subset data in R [on hold]

I have several time series and want to regress the dependent variable on the explanatory variables. My question is: Because of structural breaks in my series I do not want to include all the ...
0
votes
0answers
11 views

graph classification task - multi label?

I have a data set in graph format representing semantic connection between terms. The data set is divided into clusters, each with several labels (not unique, or mutually exclusive, no set number of ...
1
vote
0answers
46 views

What is the difference between lm(log(y) ~ x) and glm(y ~ x, family = gaussian(link = “log”))? [duplicate]

Is all in the title. I would like to know if there is any difference in terms of coefficients, residuals, p-values, but also conceptually.
0
votes
0answers
15 views

Interpretation of multinomial probit using MNP package

I used MNP to analyze the election in 1992 and I want to know the probability that non-partisan voters vote for Bush when the personal economic condition varies and the effect of education is ...
0
votes
1answer
20 views

How to do power analysis for two-way analysis of variance? [on hold]

The pwr library can be used to do power analyses when testing with 1-way analysis of variance. Are there similar libraries for 2-way ANOVAs? How could I got about doing this in R?
1
vote
1answer
52 views

Likelihood ratio tests using ML vs. REML

I am using Mixed effects models (nlme package in R) to choose the model with the best random and fixed effects. I am following the procedure of Zurr et al. (2009) ...
0
votes
0answers
14 views

Test if two means are significantly different in R [duplicate]

I would like to test if two means are significantly different from each other. I am using R and I do this: t.test(SampleA,SampleB) and I get output that looks ...
0
votes
0answers
12 views

Summary statistics for imputed data from Zelig & Amelia [migrated]

I'm using Amelia to impute the missing values. While I'm able to use Zelig and Amelia to do some calculations... How do I use these packages to find the pooled means and standard deviations of the ...
0
votes
0answers
9 views

Plot histogram using ggplots to be similar as hist() in R base [migrated]

I am new with ggplot2. I am using it to plot a histogram. Here is the code ...
0
votes
0answers
8 views

Choice based conjoint latent class analysis in R

How can we perform Latent class Analysis for choice based conjoint data, to both segment respondents and determine co-efficients for attributes at the same point of time? I know there is a package ...
5
votes
1answer
38 views

How to deal with factors with rare levels in cross-validation?

Suppose in a regression analysis in R, I have a factor type independent variable with 3 levels in my train dataset. But in the test data set that same factor variable has 5 levels. Therefore I can not ...
0
votes
0answers
9 views

Plotting QDA projections in R

When doing discriminant analysis using LDA or PCA it is straightforward to plot the projections of the data points by using the two strongest factors. This can be done in R by using the x component ...
0
votes
0answers
14 views

How to test for interactions of continuous measure with two repeated-measures factors in R?

I am doing an items analysis of difficulty ratings of a large set of math problems which were constructed to represent the factorial combinations of two binary factors, feature1 and feature2. The ...
0
votes
0answers
21 views

Negative binomial mixed effect model for repeated measures with R - prediction and plotting

I have a dataset to analyze in which a response was recorded at the ends of months 1,3,4,5,6 in 187 patients. All patients had the responses recorded in each week, and all patients started a treatment ...
0
votes
1answer
10 views

Random Coefficient Negative Binomial Model

I have a crash count data and i want to build a random coefficient negative binomial model in R. The dependent variable will be the crash counts and covariates will be Lane width, AADT, shoulder width ...
0
votes
0answers
10 views

Jackknife estimator for coefficient of variation

I have one of the estimator of coefficient of variation and i am using jackknife method to reduce bias. I am running R code to do the simulation for this study. The result i am getting is not what i ...
0
votes
0answers
14 views
0
votes
0answers
21 views
+50

Can I use deviance to compare the fit of a model to different datasets?

I'm using R's nls to fit different datasets to the same model. I've read that using R-squared is usually not correct for ...
2
votes
1answer
44 views

Forecasting daily visits using ARIMA with external regressors

I have daily visitors data for the last 10 years. I want to do some basic tests like which is the busiest day, which is the busiest month, busiest week etc. I used ...
0
votes
0answers
11 views

How does the “summary” function that is run on a principal fitted components function work?

I'm playing around with the ldr package in R, which comes with Big Mac data. If I run this code (which is similar to one of the examples): ...