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

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
9 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 ...
0
votes
0answers
4 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
8 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
5 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
20 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
21 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
33 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
12 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, ...
0
votes
0answers
15 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
19 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
13 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
9 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
20 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
25 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
33 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
31 views

Removing additive effect in Multiple Regression in R

I have this data set that I will used for my model ...
2
votes
2answers
48 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 ...
3
votes
1answer
29 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
26 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
20 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
6 views

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
40 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
28 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
84 views

R Time Series Forecasting: Questions regarding my output

I'm working on a forecast for the following data: ...
2
votes
1answer
81 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 ...
1
vote
0answers
5 views

R lda() graphing with two groups - histogram or scatterplot?

I am using a discriminant function analysis to see which environmental variables best discriminate my study wetlands into those occupied by a species and those not occupied. I have 23 wetlands and ...
0
votes
0answers
3 views

using hclustvar in R, it clusters the column headings but I want it to cluster my row headings

I have a data matrix with quantitative and qualitative variables as columns and species as rows. I would like to cluster the species in terms of the variables, but it keeps clustering the variables. ...
1
vote
0answers
8 views

Standardized Regression Coefficients for categorical interactions: lm.beta() vs. regressing standardized variables

I am working with a regression model from which I would like to compute standardized regression coefficients. I am writing primarily regarding an observed discrepancy between coefficients obtained by ...
1
vote
0answers
12 views

Maximum number of alternatives in a discrete choice model

We are modeling a discrete choice scenario, with alternative-specific coefficients. We also break the assumption of independence of irrelevant alternatives. To model this, we are using an ...
0
votes
1answer
13 views

perfect variable separation, determine cutoff via ROCR package in R

I am developing a logistic regression model where perfect variable separation occurs. I want to calculate a cutoff from this data. Interestingly, the length of the slot ...
1
vote
0answers
16 views

How to merge different predictive models training with different data sets?

Is there any good method to merge/consolidation different predictive models which were trained on different features but outputs the same goal. Example: Model 1 with features a + b + c (trained on ...
0
votes
0answers
29 views

How to account for repeated measurements and unequal sample sizes in RDA

I have a question going in the same direction as this one: Restricted Permutations However, I have a dataset of multiple Locations from which I have samples of sometimes 5 sometimes only 3 years. Not ...
0
votes
1answer
30 views

Buiding Ensemble model

I'm new to ensemble model. Suppose I've KNN models like this - (in R) library(class) ...
-3
votes
0answers
17 views

prediction of class label from training dataset

I have generated class association rules using a training data set. The task is to predict the class label for a new data set without given class labels and verify that the previously rules suit the ...
0
votes
0answers
20 views

Getting the probability density kernel estimator with R

I am working on a density estimation project and I need to get an estimation of the density as well as an equation for the density estimator (and not the estimate). I am working with kernel ...
2
votes
0answers
26 views

mixed effect model design with a sampling variable

I am trying to specify a formula for a linear mixed effect model (with lme4) for my experimental design, but I'm not sure I'm doing it right. the design: basically ...
1
vote
0answers
11 views

Binary decision, evaluating Bayesian probit regression?

Laplacian logistic regression. I have a training set of data and an evaluation set. The response is binary. I have to verify the models by calculating posterior predictive on the evaluation set. Last ...
0
votes
0answers
14 views

Separating the Intercept in many Dummy Variables in Multiple Regression in R

I did a multiple regression on a dummy variable using R about how much people will pay on a certain product. Given this variables and levels: ...
-1
votes
0answers
11 views

Usage of periodicity transforms in practice [on hold]

After a long and exhaustive search for the most appropriate transform for my problem, I have found some help. The periodicity transform at the link should work like a treat. Unfortunately I could not ...
1
vote
0answers
51 views

Can you calculate the power of a Kolmogorov-Smirnov test in R?

Is it possible to do a power analysis for a 2-sided Kolmogorov Smirnov test in R? I am testing whether two empirical distributions differ using ks.test(), and am looking to add a power analysis. I ...