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

Could anyone help me check my gibbs sampling code?

I am now trying to write a Gibbs Sampling code based on the posteriors from a paper "Bayesian Regularization via Graph Laplacian", writer: Fei Liu, et. When I run the code, it always show the error: ...
-1
votes
0answers
12 views

How do you combine data with multiple datasets? [migrated]

I'm having trouble combining a bunch of different data sets together. When I combine them, the variables v1, v2, and id combine into two separate columns where there's 3 different numbers per cell ...
0
votes
0answers
10 views

Instrumental variable analysis after (propensity) matching

I am trying to replicate the methods used in this paper by Paul Rosenbaum and colleagues (Near-Far matching). I have been studying the methods in the referenced papers by Michael Baoicchi. My work ...
0
votes
0answers
7 views

How can I obtain the Simulations in CausalImpact package? [on hold]

Currently we are using your package CausalImpact to evaluate the effect of different interventions over the accident occurrence in different firms. I address to you in order to ask you if there is any ...
0
votes
0answers
6 views

r ggplot 2 - set different fill colors for different facets [migrated]

Using ggplot2 in R, I want to set the fill parameter to be different for each facet. Here is some simplified code (Also ...
0
votes
0answers
9 views

How to perform Sensitivity Analysis of Bayesian network using R?

I know there are similar techniques for Sensitivity Analysis for Random Forests. I am looking for something similar for Bayesian Networks. I have built the Bayesian Network using bnlearn package in R. ...
1
vote
0answers
11 views

RandomForest MeanDecreaseAccuracy interpretation

I know there are already some questions regarding the interpretation of the MeanDecreaseAccuracy metric of the randomForest-package, but it's still unclear to me. My assumption was that each variable ...
0
votes
0answers
6 views

How to draw a efficient sample variogram using gstat package in R? [on hold]

I have a csv file named seoul3112, contains PM10 concentrations. please, download..I have tried to plot sample variogram and fit a model on it. ...
3
votes
0answers
16 views

How to calculate uncertainty in bacterial growth rates (or in the slope of any local regression)?

I'm using a plate reader to measure optical density of different bacterial strains so I can compare their responses (growth rates and changes in them over time) to stress conditions. The growth curves ...
1
vote
0answers
31 views

Why can't my (auto.)arima-model forecast my time series?

For testing I generated a very simple time series with a clear recurring pattern. I expected that auto.arima will generate a model, that can forecast that pattern, but óbviously it doesn't. Can anyone ...
-4
votes
1answer
48 views

what's wrong with my data? [on hold]

I want to analysis the customer churn with logistic regression, no matter what I delete the data, I always receive the result I don't want to see...like this... I delete data from sample size 66xxxx ...
0
votes
0answers
13 views

How do I make a piecewise constant formula term? [migrated]

I can produce a model matrix for a piecewise linear spline like this: ...
0
votes
0answers
7 views

How to visualize a significant interaction between two linear predictors using the rms package?

Two linear predictors interact significantly (see below). How can I visualize this interaction in a plot? ...
0
votes
0answers
22 views

How do you turn the output of a nnet neural network model into an equation?

Assuming the output of the above nnet feedforward model (nnetModel) is such that the following summary is produced: ...
0
votes
0answers
12 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
13 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 ...
3
votes
1answer
30 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 ...
-2
votes
0answers
18 views

mfp implementation in Stata and R [on hold]

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
11 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
23 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 ...
1
vote
0answers
27 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
18 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
16 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
27 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
1answer
27 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
32 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
7 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
28 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
81 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
36 views

Using lm() with just one variable in R

I've got some baseball stats, RBIs by season, let's say: ...
1
vote
0answers
18 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
20 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
34 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
23 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
29 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
40 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
27 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
28 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
1answer
32 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: ...