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

Vectorizing code to calculate (squared) Mahalanobis Distiance

Say I want to to calculate the squared Mahalanobis distance between two vectors $\vec{x}$ and $\vec{y}$ with covariance matrix $\mathbf{S}$. This is a fairly simple function defined by ...
0
votes
0answers
4 views

Operating characteristic curve in R - determining sample size

I need to determine sample size for fixed factor model using OC Curve, given significance level, power, number of groups, sample group means. I tried using ...
0
votes
0answers
7 views

How does the Proxy::dist package for r compute cross-distance matrix between two matrices?

I am trying to understand how a cross-distance matrix between two matrices is computed, and what is the meaning of this. Can anyone help? Maybe a simple example would help, two matrices having nrow ...
0
votes
0answers
2 views

Why might an observation's predicted class probabilities differ from its predicted response in a svm classifier? How can I use both?

I'm using support vector machines to classify an image. I'm new to statistical learning. Using the ksvm package in R I've found that the predicted response is often different than the class with the ...
1
vote
1answer
18 views

Neutral Networks with Categorical Data

I'm building a neural network in R with the neuralnet package, and the data contains categorical values. I have converted the columns into dummy variables, but I have a couple of questions: I ...
0
votes
0answers
16 views

ggplot2: How to curve small gaussian densities on a regression line? [on hold]

I want to graphically show the assumptions of linear (and later other type) regression. How can I add to my plot small Gaussian densities (or any type of densities) on a regression line just like in ...
0
votes
1answer
35 views

Could one say that one dataset is distributed more normally than another?

I am trying to fit a simple linear model: experiment ~ calculated_1. From the basic model, I get residuals_1. And I know that ...
5
votes
1answer
35 views

What are the fitted values in a random effects model?

Consider a linear random intercept model: \begin{align} y_{ij} &= A_{i} + \varepsilon_{ij} \\ A_{i} &\sim N(0,\tau^2) \\ \varepsilon_{ij} &\sim N(0,\sigma^2) \end{align} where, $A_i$ ...
0
votes
0answers
12 views

R train random forest for positive or negative predicitve value, not accuracy

I am working with random forests on financial data (predicting if stock rises versus falls). I figured out that I get better performance, if I build one model for "rising" and one for "falling". ...
0
votes
0answers
17 views

LRT with imputed data in R

I would like to estimate LRTs for nested models using imputed datasets and the survey package in R. I have this: ...
0
votes
1answer
27 views

Logistic regression with bootstrap, how to interpret high standard errors and choose coefficient?

I am attempting to do a logistic regression bootstrap with R. The problem is I get high SE's. I'm not sure what to do about this or what it means. Does it mean that bootstrap does not work well for my ...
0
votes
0answers
12 views

Hardware for Neural Networks in R [on hold]

I am building neural networks in R using the neuralnet package. I am going to build a new PC just for this purpose. Where is my money best spent? Just I put as much ram as I can afford in it? Will ...
0
votes
0answers
11 views

Pointwise Confidence and Prediction Intervals with LMER {lme4}

I am trying to return the pointwise confidence and prediction intervals for a linear-mixed effects model using random intercept and slope, but I'm getting errors in my code. ...
0
votes
2answers
30 views

Generating a simulated dataset from a correlation matrix with means and standard deviations [duplicate]

I have a standard correlation matrix from an academic paper with means and standard deviations: ...
0
votes
0answers
12 views

r glmer warnings: model fails to converge & model is nearly unidentifiable

I have seen questions about this on this forum, and I have also asked it myself in a previous post but I still haven't been able to solve my problem. Therefore I am trying again, formulating the ...
2
votes
0answers
20 views

Implementing random forest to predict the success rate and time of completion

I have a large dataset with more than 120 columns for which I'm trying to classify whether the order will be successful or not. There are two parameters that I need figure out. One is the probability ...
0
votes
0answers
16 views

How to turn nlme syntax into manuscript appropriate equation?

I ran an linear mixed-effects analysis in R using the nlme package. I would like to write out the algebraic equation of the model's specifications. Unfortunately, I do not know exactly how to ...
1
vote
0answers
13 views

predicting the percentile of response variable via linear regression of zscores

Sometimes during modeling we are faced with non-normal data. One of the presumptions of linear regression is the response data being normal. I wish I found a better example data set to illustrate ...
0
votes
0answers
5 views

How to remove zonal anisotropy from directional variogram using gstat in R?

I have a dataframe named seoul315 contains the 107 data of PM10 concentration at 1 march,2012,5.00 am. please, download. I have tried to plot semi-variogram for kriging bt the following code: ...
1
vote
1answer
58 views

In R, what does qqnorm actually do?

qqnorm(x) plot(qnorm(seq(80)/81),sort(x)) Finding that the plots produced by the commands above are slightly different from each other, I tried this: ...
2
votes
0answers
38 views

Why is the derivative not zero?

I am working with survival models and I am using R's coxph function to learn the Cox proportional hazard model. To try it out, I am using the standard veteran dataset (obtainable by loading the ...
0
votes
3answers
59 views

Question on Residuals

After generating the regression model in R using lm, the results will be passed to summary function. results <- lm(y~x, data) summary(results) This function ...
0
votes
1answer
17 views

Effect of “parameters.to.save” in R2jags/ JAGS

I'm using the package R2jags in R, which uses the parameters.to.save argument to specify parameters. I'm interested in the statistical distinction between a ...
0
votes
0answers
6 views

Restarting Lag based on Change in Name in Different Column [migrated]

I am trying to insert lags of a variable into a separate column in my data frame on R. However, I want the lags to 'restart' every time the name in a different column changes. An example of data is ...
2
votes
2answers
50 views

Why log-transforming the data before performing principal component analysis?

Im following a tutorial here: http://www.r-bloggers.com/computing-and-visualizing-pca-in-r/ to gain a better understanding of PCA. The tutorial uses the Iris dataset and applies a log transform prior ...
0
votes
1answer
34 views

Density forecasting

I am having some troubles obtaining density forecasts of any returns series. As I couldn't find any numerical examples on the Internet, I would like to ask you guys for some help. My goal is to ...
0
votes
0answers
11 views

What is VectorSource and VCorpus in 'tm' (Text Mining) package in R

I'm not quite sure what exactly VectorSource and VCorpus are in 'tm' package. The documentation is unclear on these, can anyone make me understand in simple terms?
0
votes
0answers
4 views

Permanent and temporary shock income, variance decomposition

I have a balanced panel data (N= 190, T=5). It's about income and personal characteristics of the householder. I would like to find the coefficients of a temporary and of a permanent income shock. I ...
0
votes
0answers
10 views

Non-parametric alternative to a mixed anova?

My data fails assumptions of variance - (norm dist is good though) - and I was wondering if anyone had a suggestion for an alternative to a mixed anova? Three repeated measures (Test 1, Test 2, Test ...
1
vote
1answer
31 views

Model selection for linear regression with categorical variables

I regressed the dependent variable Rating (numeric) on Judge which is categorical. The output of the first model is given at the end of the question. Only Judge John Foy and Linda Murphy came out to ...
0
votes
0answers
7 views

Model selection for linear regression with categorical variables [duplicate]

I regressed the dependent variable Rating (numeric) on Judge which is categorical. The output of the first model is given at the ...
0
votes
0answers
12 views

How to define smooth.terms in GAM?

I am new comer in GAM. I read into gam introduction but still confused below questions: 1) how to know which independent variable need to be smooth ? To make smooth terms, now I try with different ...
0
votes
0answers
14 views

How do I Forecast new Yts given new Xt's using a Dynamic Linear Model?

I am trying to forecast predict new observations of interest rates given new data using the DLM modeling framework. Essentially, my problem is this: I have a training set (a set of data i want to ...
1
vote
2answers
113 views

How to standardize the variables in R for regression analysis

I have been looking at some tutorials and articles and couldn't get a scenario where two variables are in different scales and used in modeling. So, firstly lets assume I have one metric of numeric ...
1
vote
0answers
15 views

plot.gam versus visreg [on hold]

I am trying to understand the difference between the two plots I see in the code below. Looking at the visreg manual pg 2 correctly and if the same applies to gam models, then visreg plots residuals, ...
3
votes
1answer
22 views

Have I correctly specified the lmer model?

a simple two-level model, with one explanatory variable at the individual level (X) and one explanatory variable at the group level (Z): ...
0
votes
0answers
21 views

Comparing means of different training programs in R

I have a data set with performance and training data that looks something like (this is not the exact data, but gives a general idea): ...
0
votes
0answers
8 views

stacked polynomial regression vs polynomial in the Xi

The Ramsey RESET (Regression Equation Specification Error Test) can tell if the model is under specified. The test can suggest that polynomial regression may be in order. ...
0
votes
0answers
23 views

Compare three non linear regression lines

I'm beginning to explore the world of the non-linear models and I'm needing to compare if there are significant differences between the slopes of three different groups. I have been reading some ...
0
votes
0answers
9 views

Calculating effect sizes for mixed effect logistic regression to determine subsequent sample size

We conducted a previous preliminary study using 40 participants. We analyzed the data using the lme4 package in R to conduct a mixed effect logistic regression. We ...
1
vote
1answer
15 views

Error terms and random effects standard deviation in multilevel modeling with R

While interpreting random effects part of the multilevel modeling with R, are standard deviations the same as error terms? For example, when the result is: ...
0
votes
0answers
17 views

How to use lagged outcome variable in CausalImpact? [on hold]

I would like to use the lagged outcome variable as regressor in the CausalImpact/bsts package. Since I cannot use the ...
0
votes
1answer
47 views

Selecting the best GLM (generalized linear model)

GLM (family=binomial) is foucusd on when the response is dichotomous(yes/no, male/female, etc..). I'm wondering how to judge if the model we built is good eough? As we know, in OLS regression some ...
0
votes
0answers
24 views

Simulate data around existing data in r

I have been working at this for sometime, surfing StackExchange and any other R webpage I can find without any luck. I am trying to simulate data to essentially recreate the attached figure with ...
0
votes
0answers
7 views

Multiple tests, summary of clogit

I have 10 exposure variables that i would like to analyze univariate. I've applied the conditional logistic regression model for each exposure and then used the summary function for each one of them. ...
0
votes
1answer
33 views

Using predict with PCR in R [on hold]

I'm trying to follow the documentation on the pcr method in R So I do the following ...
1
vote
0answers
13 views

Encode special values in continous predictors

I have continuous variable with missing values. Missing values are of different types (indicated by special values such as 991, 992). How do I best encode my data for logistic regression? I can create ...
0
votes
0answers
12 views

How to specify a multi-instrument 2SLS [migrated]

I'm looking for a compact way to specify a multi-instrument 2SLS in R. Imagine that there are four treatment categories (A, B, C, and D). There are two waves of measurement, Y_1 and Y_2. A ...
1
vote
1answer
24 views

The `Shepard` function in R package `MASS`

The function Shepard is listed in the help file for MASS::isoMDS, but nothing is said about it. What does this function do?