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

Calculating Odds Ratios from R output

My question is how do I calculate the Odds Ratio for country 2 relative to country 1? Also, how do I calculate the Odds Ratio for country 2 relative to country 3? Thanks :) 
0
votes
0answers
6 views

Different quantile values for a predictor between the root data and and the data of a Predict() object

I want to plot a continous predictor using restricted cubic splines and indicating the distribution of the linear predictor using a box-and-whisker plot. However, the quantile values differ from those ...
0
votes
0answers
8 views

extract the idosyncratic error of a factor model

I want to extract the idosyncratic error $e$ of a factor model which has the form $X = F \Lambda' + e$. I estimated the factors $F$ and the loadings $\Lambda'$ by principal components in ...
1
vote
0answers
12 views

Why can't we use top-down methods in forecasting grouped time series?

As I asked in here I was trying to forecast grouped time series with two grouping variables and I find some limitation of hierarchical forecasting methods. In particular, using hts package from R, we ...
-1
votes
0answers
8 views

mfp implementation in Stata and R

I am applying multivariate fractional polynominals on data, which have 30000 (observations) x 20 (variables). Surprisingly, mfp in R is quite fast (10 minutes), but mfp in Stata is very slow (stuck ...
0
votes
0answers
8 views

SV in R: non-constant volatility for parameter estimation (Heston)

I'm trying to estimate the parameters of a stochastic volatility model (like Zhang & Zhu, 2006) in R but instead of a constant volatility having a function (iv). This function can be estimated by ...
0
votes
2answers
19 views

Grouping customers together into like groups based on multiple variables without a categorical variable

I am looking for a little guidance as to the correct approach to this problem. We have a list of IDs and roughly 8 different numerical variables such as quantity and revenue. Each ID is unique to the ...
0
votes
0answers
21 views

Tennis Analytics: How to Build Model Predicting Player Service Point Win %

I have collected a large amount of tennis match data including player names, court surface, player ranking points at time of match, handedness of player, point by point breakdown of match etc. I ...
0
votes
1answer
15 views

Iris dataset and a-priori probabilities

I have been playing around with two R packages for naive Bayes classification (e1071 and klaR) using the Iris dataset as an example. During the training phase, the outpur of the apriori probabilities ...
0
votes
0answers
15 views

Does anyone know if the portable version of R works on both Windows and MAC? [on hold]

I installed the portable version on my USB. I was wondering if anyone knows whether it will work on both my windows pc and Mac?
2
votes
1answer
12 views

How to compare two spatial points patterns in R?

I have two spatial points data sets (relocations of animal A and distribution of plant B). How can I investigate if animal A is more likely to be where plant B is present? With the animal ...
1
vote
0answers
17 views

R - moderated mediation using the lavaan package

I am interested in determining the conditional indirect effects of X on Y at a series of values for a third variable Z. I was able to use the lavaan package to calculate some initial indirect ...
0
votes
0answers
26 views

Daily Category Revenue Stacked Bar Chart in ggplot2 [on hold]

I am trying to use the ggplot2 to build a daily Category Revenue chart. The chart would look similar to this, but with date on the x-axis, and total revenue on the y axis. The fill would be the ...
0
votes
0answers
6 views

Cox model with known measurement error

I am trying to perform a univariate Cox PH survival analysis in R. My covariate was generated from another analysis, meaning that I have a 95% CI range (between 0 and 1) for the values. Right now, I ...
0
votes
1answer
25 views

Comparing regression models with different coding of the same linear predictor

How can I determine whether one coding of a linear predictor leads to a better fit of the corresponding regression model than the other? In the following example, the restricted cubic spline coding of ...
1
vote
2answers
68 views

significance test for yes/no data in R

I have the following data format: ...
0
votes
0answers
28 views

Why Removal of Outliers Does not Affect Confidence Interval [on hold]

I have a question regarding why confint(), a function in R which returns a 95% confidence interval when applied to a linear model, returns the same result even when I remove the single greatest or ...
1
vote
1answer
35 views

Using lm() with just one variable in R

I've got some baseball stats, RBIs by season, let's say: ...
1
vote
0answers
15 views

Kalman filtering in [R] : FKF package and DLM

I am trying to implement a time varying state-space model in [R]. Model includes some exogenous variables that are part of the measurement and transition matrices. I tried multiple packages and my ...
0
votes
0answers
16 views

Work with results of tbats decomposition

I made a time series decomposition with tbats. There is weekly and yearly seasonality in the data (and maybe also monthly - not really important for the question) ...
0
votes
0answers
7 views
0
votes
0answers
8 views

Error in eval(expr, envir, enclos) in apply(boxcox) [migrated]

I have a matrix of about 650 columns and for each column I want to find the optimal lambda for the boxcox transformation. I want to use the function boxcox from the MASS package, which outputs two ...
1
vote
0answers
19 views

Estimating a plane from a set of 3D points

I am trying to estimate a midplane of a 3D model using the midpoints of paired landmarks, in order to reconstruct missing data. I therefore need to estimate a midplane from 27 3D points. I have looked ...
0
votes
0answers
7 views

Simulation of Generalized linear mixed models with normal random effects and binary response variable with R [on hold]

My aim is to study the behaviour of the Laplace approximation with different type of response variables, starting from a binary one. However i'm stucked far before that: i have to simulate with R the ...
0
votes
1answer
31 views

Test to determine observed vs. expected (not Chi-square)

I will work through how and what type of data I am getting before I ask my question: I made some code in R that flips n fair coins x times, and sums the number of successes (heads = 1, tails = 0) I ...
0
votes
1answer
20 views

How to get weighted summaries of survey responses in R

I am analysing survey data. Since my demographic categories are discrete I can summarise responses within demographics using prop.table. However, I would also like ...
1
vote
0answers
22 views

Online time series forecasting with DLM

I have estimated a univariate time series model, consisting of a random walk and an AR component. Now the goal is to make forecast about a couple of steps ahead as new data comes in, in an online ...
1
vote
0answers
26 views

Interpretation of various output of “lmer” function in R

library(lme4) fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) The notation (Days | Subject) says to allow the ...
0
votes
1answer
30 views

Finding pattern from sparse matrix

I have a large sparse matrix which represents whether the action is happened or not. Each columns represent each action. Each row represents time. The data is collected for every 15min. Zero in the ...
0
votes
0answers
26 views

Naming convention for column names

I have a general question. Is there any rule or convention about how to name columns in general (CSV, R, relational databases and so on)?. If I need to be more specific, I would like to know for R. I ...
0
votes
1answer
25 views

Help evaluating a model in R

I am a newbie in R and I am trying to do my best to create my first model. I am working in a 2- classes random forest project and so far I have programmed the model as follows: ...
0
votes
1answer
31 views

Can anyone help me with R code for the two-step generalized method of moments (GMM) [on hold]

I am new to R and need to do a 2 step Generalized Method of Moments estimation. Can anyone help me with an example code. Thanking you.
0
votes
0answers
20 views

Creating a test set with imbalanced data

I am working on a binary random forest using R. mu data set consists of 300 cases classes 1 and 2100 cases class 0. I am planning to evaluate my model using the model prediction and the AUC and for ...
1
vote
1answer
34 views

Generate independent random values from a bivariate normal distribution

I am trying to independently select two sets of numbers (set 1 and set 2) from a bivariate normal distribution. I want the ...
0
votes
0answers
24 views

Using update() with lmer() for fixed effects only [on hold]

I think this may be a very simple yes/no answer, but I can't find anything in the docs. I'm doing a series of linear mixed model comparisons with lme4. For each comparisons, I'm adding a single new ...
0
votes
0answers
8 views

Using R to calculate between- by within-subj ANOVA interaction contrasts using car or lme [migrated]

Psychology student here. As part of my thesis I have some data from an experiment with two between-subjects IVs, classification and ...
0
votes
0answers
8 views

Splitting DocumentTermMatrix in R [migrated]

I'm looking to create a word pair prediction function, but am having trouble working with DocumentTermMatrix to data frame or similar to use in prediction function. Here is my working code: ...
-1
votes
0answers
17 views

How does the cross validation function in R work when the sample size is non divisible? [on hold]

How does the cross validation function in R work when the sample size is non divisible by the number of folds?
-1
votes
1answer
24 views

Cross validation when only the regression equation is given [on hold]

Is there any function in R to conduct cross validation when you only know the regression equation?
1
vote
0answers
36 views

Inconstant logistic regression coefficients each time algorithm is run [SOLVED] [on hold]

I'm running a logistic regression to find a relationship between falls and drugs taken by someone. What happens is that every time I re-run the algorithm it gives a different result. The table is ...
1
vote
0answers
16 views

Interpreting silhouette coefficeint for clara function in R

I am trying to do clustering on a distance matrix which contains numeric data. But I am not sure how to decide upon the number of clusters or value k for clara function in R. But after running it with ...
4
votes
2answers
117 views

Comparing a linear model with a spline model

I try to figure out how to describe my continuous variable. Unfortunately, I did not understand all of the statistics. I would really appreciate I you guys would help me out here. To better illustrate ...
0
votes
0answers
36 views

Using BIC,AIC for estimating number of clusters in document clustering using Kmeans

In my approach I am trying to find the optimal value of 'k' for clustering a set of documents using KMEANS algorithm. I wanted to use 'AIC' and 'BIC' information criterion function for finding the ...
-1
votes
0answers
21 views

Maximum important variable using PCA [on hold]

In the following figure of biplot for PCA, can I say that petal.length and petal.width are most important variable in iris dataset because they are explaining most of the variance of the whole ...
0
votes
0answers
21 views

Type one right censored data [duplicate]

Does anyone have any idea about how to simulate censored data in R? For example, generate a sample of 200 with 30% of that Type 1 right censored, based on Weibull distribution. (30% of 200 = 60).
1
vote
0answers
7 views

Backing out fixed / random effects in lmer mixed model

Assume that I have a linear mixed model of the following form, specified using lme4: fit <- lmer(A ~ B + C + (1|D) + (1|E), data=data) I am struggling with ...
1
vote
1answer
31 views

Proper way to cite R help?

I want to cite the R help description of a function. Is there a proper way to cite the R help? Or should I simply cite the package of the function?
0
votes
0answers
11 views

Correlated errors within group with nonvarying dependent variable

I am trying to run a model in R to show how well one survey (SurveyA) predicts responses to another survey (SurveyB). SurveyA has 20 questions and we get an estimate of the participant's parameter ...
-1
votes
0answers
9 views

how to give classes to hclust output at specific height [on hold]

Am new to R , Using rect.hclust(fit2, h=10079,border="green") draws green rectangles around the matched points, how can I assign classes to these points and print ...