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
1answer
12 views

How to do power analysis for two-way analysis of variance?

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
37 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
12 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
2 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 ...
3
votes
0answers
17 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
7 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
10 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
17 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
9 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
9 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
13 views

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 ...
0
votes
0answers
28 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
10 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): ...
1
vote
0answers
19 views

Fitting an envelope to x-y data in R

I have some data that I'd like to create an envelope for it. As in the picture, the data is always positive and I'm looking for something that will capture my crudely hand drawn red line. It should ...
1
vote
0answers
23 views

Different variance estimator for multilevel ordinal logistic regression in Stata and R

I estimate a multilevel ordinal logistic regression models in Stata and R, and receive different estimators for the variance and the covariance of the latent variable of the higher level. Among other ...
0
votes
0answers
9 views

R and fisher test in each row in a data frame [on hold]

![enter image description here][1] I basically have this dataframe and I would like to do a fisher test on it to see which of thoses elements are present more ...
0
votes
0answers
9 views

skip -9999 and perform multiple regression [on hold]

I want to do the multiple regression where SMDI is my dependent variable and other are my independent variable. I have following dataset to do the multiple regression: SMDI ET PRCP ET_Ch ...
0
votes
0answers
7 views

generating a sequence of indicators based on variable boundaries in JAGS

Suppose I have a vector of indices 1:N, and data y[1], ..., y[N]. I have three variable center points in ...
0
votes
0answers
28 views

Poisson Distribution - rpois - NAs produced [on hold]

I am new to R (a student) and running a Poisson distribution on football scores. head(results0910) works perfectly, showing me that my teams and scores are read in ...
0
votes
1answer
24 views

Measuring impact of advertising on retail sales

I have a dataset of retail products which contains weekly sales for 12 different items in a single category. For each item, I have three dummy variables representing different types of advertising ...
0
votes
0answers
40 views

Difficulty plotting regression in R

I am trying to plot a regression using plot() and keep getting the error message "Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ". ...
0
votes
2answers
19 views

Prediction of features given predictor

I am working on a problem where my objective is to predict y given some features x1,x2,x3,...x8,x9 I solved this problem using some statistical and machine learning techniques like regression, trees, ...
2
votes
0answers
27 views

Two-Way Repeated-Measure design with lme4

I would like to model a treatment effect in two different groups, controlled for some co-variates (like age and education), and I assume that a two-way repeated-measure Anova would be the right ...
0
votes
0answers
47 views

Assessing the need for random effects terms

During the model selection phase for mixed models, there are typically several possibilities to choose from; in fact, the number of possibilities is increasing in the number of covariates used. How ...
0
votes
1answer
16 views

Do the values in the second factor from a principal component analysis have to have different signs?

I am computing the principle component matrix of a financial database and to obtain the second factor I extrapolate the second vector. So far, it's easy, but I wonder, do the signs of the second ...
1
vote
0answers
6 views

Calculating Diversity using normalized species counts

I am trying to calculate the change in diversity of species encountered throughout time. My dataset is comprised to detections of tagged fish for 48 consecutive weeks. My thought was to bin the ...
-1
votes
0answers
10 views

which package in R perform k-prototype algorithm? [on hold]

I have mixture of nominal and discrete numerical data.I want to cluster the data and as i know some clustering algorithms such as k-means are not appropriate for clustering mixed data.So i want to ...
0
votes
0answers
17 views

Stat test to use with nominal variables

I have a research question looking at whether one level of a nominal variable is more likely to elicit an action than another. We are using a control and experimental group so our IV is either ...
1
vote
1answer
22 views

Sampling intercept and slope pairs from lm in R

Let's say I have a model Y~X+trt, and by running lm and summary functions in R I get these results: ...
0
votes
0answers
28 views

Correlation with categorical variables - Interpretation of aov()

I want to know if one (or more) out of three categorical variables (season of measurement, geology, grazing) influence the numerical variable (spread of a plant). Sure, I read the answers here ...
0
votes
0answers
15 views

Copula Quantiles in R? [migrated]

I have the following bivariate Copula models: Archimedean copula family:- Gumbel-Hougaard Copula ( Model-1) Frank Copula ( Model- 2) Elliptical copulas family Normal Copula(Gaussian Copula) ( ...
0
votes
0answers
6 views

Aggregating Equity Intraday Ticks

I am currently working with intraday equity data. The ticks are sourced from Bloomberg API. Bloomberg only timestamps down to the second (not millisecond) and data is not in order. In many instances ...
1
vote
0answers
10 views

Find significantly different element

I have following data and want to know is there really significant difference between those five objects: I have 5 objects and 3 different tests and their results like this. So this is very few rows ...
2
votes
1answer
34 views

Implementing Gibbs sampler in R from posterior distribution

I am referencing a follow-up idea from something I posted earlier (Zero-inflated Poisson and Gibbs sampling, proofs and sampling). I want to implement the Gibbs sampler, by generating a large ...
1
vote
0answers
35 views

Removing additive effect in Multiple Regression in R

I have this data set that I will used for my model ...
2
votes
2answers
51 views

kappa coefficient doesn't make sense

I am calculating Cohen's Kappa to assess agreement. Here is my contingency table: 0 1 0 23 17 1 59 457 So the observed probability of agreement is high ...
0
votes
0answers
19 views

Is there any argument in GAM function (R software) to tell the model which variables are categorical or continuous? [on hold]

I want to fit a species distribution model for some bat species using a generalized additive model (GAM). I have 124 presence points and I generated 10000 random absence points. I also have 18 ...
4
votes
1answer
33 views

Discrepancy between metafor and weighted lm() standard errors

My friend and I are trying to understand why a weighted lm() v. a fixed-effect rma model from the ...
3
votes
1answer
27 views

Zero-inflated Poisson and Gibbs sampling, proofs and sampling

I am trying to figure out zip-inflated Poisson (ZIP) model. In this model, random data $X_1, .., X_n$ are of the form $X_i=R_iY_i$, where the $Y_i$'s have Poisson distribution ($\lambda$) and the ...
1
vote
0answers
26 views

Stata vs. R survival differences; weibull scale is different, problems predicting manually

I am trying to do some survival analysis in R and as a starting point, I want to make sure I can replicate a previous analysis. I notice differences and I will demonstrate them here. I feel like there ...
0
votes
1answer
14 views

State space models in dlm package - how to add a non time-varying constant?

I am trying to compare the following two models: \begin{align} y_t &= \beta_{0,t} + \beta_{1,t} x_{t} + \epsilon_t\\ \beta_{1, t+1} &= \beta_{1,t} + \eta_t\\ \beta_{0, t+1} &= ...
0
votes
0answers
7 views

Can I customize preprocesses in R caret's package? [migrated]

I am using the caret package for training regressions. Since I came across of it, I knew I was gonna need it. I have looked at the section for preprocessing the ...
0
votes
0answers
18 views
+50

Moment Conditions for Stochastic Discount Factor (SDF)

Following extract has been taken from Computing Generalized Method of Moments and Generalized Empirical Likelihood with R, the Vignette of gmm R package. In some ...
1
vote
1answer
58 views

Problems with time series prediction

I got a question about modeling time series in R. my data consist of the following matrix: ...
2
votes
1answer
29 views

When is mu_a used in this STAN example?

I'm looking at an example of a random effects model with 2 random effects fit by Peter Li demonstrating how get models fit in lmer into STAN. The code for this and the accompanying data are stored ...
2
votes
1answer
114 views

R Time Series Forecasting: Questions regarding my output

I'm working on a forecast for the following data: ...
2
votes
1answer
83 views

Generate data with skewed distribution and known percentiles, mean and median

I'm trying this one again as my imprecise use of language unfortunately confused my last attempt at this question... I am trying to recreate some data from a publication. The study was on levels of ...