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

Group data under conditions! [migrated]

First of all, I would like to thank you for your time. I am working with R on cross-section data and having a problem when group the data under conditions. The problem can be seen clearly from a small ...
-1
votes
0answers
11 views

R -Pediction Interval of Random Forest

I am using quantregForest package to calculate the prediction interval, but the results are disappointing. The code is: ...
0
votes
0answers
7 views

How to use trained caret object to predict on new data (not used while training)?

I am using caret package to train random forest model on training dataset. I have used 10-fold cross validation to get an object say ...
1
vote
0answers
8 views

How to use formative indicators in covariance-based SEM with lavaan?

I'm trying to build a covariance-based structural equation model (SEM) using both reflective and formative specifications of latent variables. I use the sem ...
0
votes
0answers
12 views

R: multicollinearity issues using glib(), Bayesian Model Averaging (BMA-package)

I am experiencing difficulties estimating a BMA-model via glib(), due to multicollinearity issues, even though I have clearly specified which columns to use. Please find the details below. The data ...
0
votes
0answers
11 views

How to predict on a new dataset using caretEnsemble package in R? [migrated]

I am currently using caretEnsemble package in R for combining multiple models trained in caret. I have got the list of final trained models (say ...
1
vote
0answers
2 views

Gaussian shape link function for glm binomial regression?

Link functions are typically sigmoid. The idea being that the underlying data is fitted to the curve with an increase in the predictor summation gives an increase in the response. However, could one ...
0
votes
0answers
11 views
0
votes
0answers
12 views

Random Forest online/incremental learning in R

Is there a Random Forest implementation available in R, that supports online learning? My alternative approach was to use the popular randomForest package and combine Random Forests (the existing one ...
0
votes
0answers
24 views

Correlation between ordinal variables

I want to know the correlations between 3 groups of variables which are ordinal (rating of 1 to 10). I have followed the formula on wiki and computed the Kendall tau-b correlation coefficients matrix. ...
0
votes
0answers
11 views

Using mean for a function in mixed model

I am using lme4 package to apply mixed modelling approach to my data. In my data I have two treatments and three populations with four replicates each. Population is fixed effect and treatments and ...
0
votes
0answers
12 views

Embed foreign exchange variation in the financial forecast [on hold]

I would like to forecast my accounts payable for next 12 months. My vendors are all over the world and I deal with different currencies. How do I factor the foreign exchange rate variation over a ...
0
votes
0answers
10 views

Bivariate time series analysis

Currently I am working on a project where I need to find out whether financial aid (per capita) has an influence on the country's HDI. I have compiled a dataset, which you can find here: ...
0
votes
0answers
3 views

Fitting Data with Ties Using unique() Walk-Around and ks.test

I'm looking for a distribution that best fits my data. Looking at the frequency plot, seems like the distribution could follow a Gamma or Weibull distribution. With that in mind, I use the ...
0
votes
0answers
19 views

R, Pairwise comparison of random variable in mixed model

We measured temperatures of a pond repeatedly every day at each hour for a month at two different depths (i.e., top and bottom). We want to see if the temperatures at the top of the pond are ...
2
votes
2answers
57 views

Least Squares Regression Step-By-Step Linear Algebra Computation

As a prequel to a question about linear-mixed models in R, and to share as a reference for beginner/intermediate statistics aficionados, I decided to post as an independent "Q&A-style" the steps ...
2
votes
2answers
61 views

How to deal with the “sure probabilty” (p=1) in logistic regression

The model of logistic regression is that: log(p/(1-p) = ...... The most interesting case (for me) is the case that we have p=1 and p=0. But in this case, the ...
0
votes
0answers
7 views

Definition of p-value in carets confusion matrix method

In the documentation for the confusion matrix method in the caret package, the p-value is described as: a one-sided test to see if the accuracy is better than the "no information rate," which is ...
1
vote
1answer
31 views

Compare distributions (with replicates) and visualization

The experimental set-up is an almost typical control vs treatment, in which we are counting how many reads map to a particular class of genes in each condition (RNA-seq), done in triplicate. An ...
0
votes
0answers
17 views

How to use Kernel Regression to predict new data?

I have climate data for 240 predictors and precipitation flux (as the target variable) for 3000+ days. I want to use Gaussian kernel regression to predict the precipitation flux for the next 2000+ ...
0
votes
0answers
32 views

When to choose which model for time series?

What are the applications of AR and MA model? To put my question exactly, when to use AR model and when to use MA model(for example, like when it is seasonal or when there is a trend, etc). In other ...
0
votes
0answers
11 views

Problem using metric='ROC' in caret train function in R [migrated]

I have an imbalanced data set with two classes therefore I thought I could use ROC as a metric instead of Accuracy to tune my model in R using caret package (I am trying different methods such as ...
0
votes
0answers
16 views

Fitting a nonlinear function where the target and predictors are transformed by a power function [on hold]

This may be a simple economics problem, but I can't figure out the terminology to google for the problem. Let's say person one has one red apple. It is $R_1$ days old. Person two has two green apples ...
1
vote
1answer
34 views

Which model of lm/lme to believe?

I have a data set of height values for several individuals of several species in 2 different conditions. Not all the species are found in the 2 conditions. I want to compare height values between ...
0
votes
0answers
7 views

How to loop through elements in a large list, make NA variables for holes in data, and create new variable in another dataframe in R? [migrated]

I am trying to find a way to avoid writing 78 lines of code by using some sort of loop in R. Say I have the following: ...
0
votes
0answers
24 views

Caclulating probabilty of drawing vector from multivariate normal distribution in R

given vector of mean $\mu$ and covariance matrix $\sigma$ as parameters of multivariate normal distribution, how can I calculate the probability of drawing $k$-dimensional vector from that ...
1
vote
0answers
15 views

Best practices to compute TFIDF matrix based on another TFIDF matrix in R

I'd like to compute a TFIDF matrix (tfidf_matrix_b) based on a previously computed TFIDF matrix (tfidf_matrix_a). Is there a ...
1
vote
1answer
39 views

Classification in real time without prior knowledge of the number of classes

Is there an implemented algorithm (with python/R or java in preference) that can classify incoming data from an unknown generator with absolutely no prior knowledge or assumption. For example: Let G ...
0
votes
0answers
45 views

Lmer v. lm with Dummy Variables. Where Does the Math Differ in a Simple Example?

I am trying to understand the concept of mixed effect along with the R syntax in lme4 with simple scenarios out of the dataset ...
1
vote
0answers
14 views

Single-factor random effect ANOVA and components of variance [on hold]

I've needed to learn some DOE for work and I've been going through Montgomery's book using R to help with the calculations. The fixed-effect models have been straightforward, but I have some trouble ...
0
votes
1answer
12 views

Fitted Confidence Intervals Forecast Function R

I am using the forecast function in R written by Rob Hyndman. I am trying to determine the best way to determine confidence intervals for the historical fitted values. I would like to plot how often ...
0
votes
0answers
15 views

model selection in quantile regression

I am quite new in quantile regression, and I am using it in R (quantreg). I have around 17 predictors,and I would like to select the best subset of predictors. Then, I was wondering if it would be OK, ...
0
votes
0answers
9 views

Caret - Changing tuneGrid gives different results for same parameters

I'm having an issue training a GBM model in caret. I'm quite new to all of this, but I'll try to explain things as best as possible, but please let me know if you need any further info. My code looks ...
2
votes
1answer
13 views

Filtering to avoid the Slutsky-Yule effect in a moving window average?

Can anyone suggest a generally accepted method of filtering time series data to avoid the appearance of artifactual oscillations when smoothing the data using a moving window average? Is it simply a ...
2
votes
1answer
19 views

What are some standard bimodal distributions?

I have plotted this curve using the default kernel density estimate function in R I am looking for some standard distribution which could be close to this. Is there any standard bimodal distribution ...
2
votes
2answers
22 views

What is the right way of computing baseline hazard rate

What is the right way of computing baseline hazard rate? To my understanding hazard rate at time t is simply #events / #AtRisk ...
1
vote
1answer
22 views

Why pnorm function and sum of dnorm function differs for same input?

Data is height of men in 'inches'. Mean is 70. SD is 3.3 I wanted to compute the probability of men whose height is in between 69 inches and 74 inches. The following methods gave me different ...
0
votes
0answers
4 views

Determining a fit test for a interupted stochastic data

I have 10s of thousands of linear data tracks (DNA sequence abundances) which I am attempting to classify by their adherence to a theoretical model. My first pass approach was quite naive, defining ...
0
votes
1answer
19 views

AIC values “Without Covariates” in R [on hold]

I've been using SAS but I'm now transitioning to R. When doing cox-regression in SAS (proc phreg) the output included AIC values "Without Covariates" and "With Covariates": The difference between ...
3
votes
1answer
24 views

R lmer confint: theta values not the same as summary values

I've been using lmer's confint procedure to compute bootstrapped confidence intervals for random effects. I noticed that extracting the theta values using "getME" produces estimates that are slightly ...
0
votes
0answers
21 views

How to Conduct a Multi-Level (3 levels) SEM in R

I've been told that there isn't a way of conducting a multilevel (3 levels) SEM analysis in R. I then found the package xxM http://xxm.times.uh.edu/get-started/ while searching online for a solution. ...
0
votes
0answers
30 views

R function for Matrix Multiplication and Addition [migrated]

After performing SVD on a matrix, I would like to create a function (I'm not good with functions in R yet) that creates a reduced matrix per my specified n-value. For instance, here is the R code for ...
0
votes
0answers
25 views

lme4: Why won't lsmeans output my fixed effects?

I'm trying to plot confidence intervals for linear mixed effects models trained with lme4 and lmerTest in R. I am using this data file, which I've shared via Google Drive. Here is my trained model. ...
2
votes
1answer
29 views

What are the formulae used in R by predict.lm when interval= a) 'none', b) 'prediction', and c) 'confidence'?

The references provided in the R documentation for predict.lm, taken together, actually leave open a number of possibilities for the formulae for confidence and prediction intervals (including the ...
0
votes
0answers
21 views

Factor Analysis

I have following data regarding Voice traffic(dependent variable) and some 10-12 other variables which are my independent variables. So, to use factor analysis shall I use voice traffic as one of the ...
0
votes
1answer
18 views

Zooming in on tail of histogram plot in R [on hold]

First off I've been using the truehist() function in R instead of hist() mainly because it looks better (but I'm pretty sure this mainly just because it has a better bin allocation). Currently, I ...
0
votes
0answers
16 views

Finding the distribution of a pormanteau test

I am trying to find the distribution of a pormanteau test for lack of fit estimating an ARIMA(1,0,1) with white noises and fitting an ARIMA(1,0,1). I know this is not the best way to obtain a certain ...
0
votes
2answers
54 views

Weird Results in Newton Raphson

I am running a simple Newton-Raphson problem in R as given below. However I am getting very weird results. Can anyone tell me where I am going wrong? ...
0
votes
0answers
13 views

How to visualize the equation line in a scatterplot of a log-linear robust regression model in R? [on hold]

The data I'm working requires me to run a robust regression with a log transformation of the outcome variable. After running the following code, ...
1
vote
0answers
24 views

Backward selection (with fastbw) in penalized logistic regression

I have a dataset with more than 20 predictors and a single binary response variable. With only $n=181$ observations (64 deaths, 117 survivors), I decided to apply penalized logistic regression to ...