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
12 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 ...
0
votes
0answers
5 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 ...
1
vote
1answer
19 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 ...
1
vote
2answers
44 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
3 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
25 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
16 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
29 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
15 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
25 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
13 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
38 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
39 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
13 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
11 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
12 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
8 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
10 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
20 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
21 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
24 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
20 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
0answers
9 views

Comparing performances of distributions

I have a Probability Distribution Function (PDF) of a new distribution given below, \begin{equation} g(x)=\frac{1}{\Gamma \left( \alpha ...
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
15 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
18 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, I decided to apply penalized logistic regression to modeling, with all predictors ...
0
votes
0answers
24 views

pvalues for fixed effect using lme function in R

I am using the lme function from nlme to run a random coefficient model. Please see the output of summary(mod1) below. I need ...
2
votes
0answers
22 views

Large differences in ARFIMA parameter $d$ using different estimators

I am trying to estimate parameter $d$ for ARFIMA model using different methods: Hurst, ML, fdSperio, fdGPH and the function arfima which selects the best fit ...
0
votes
0answers
5 views

R predict on xts object not generating dates for future forecasted points [migrated]

I have a data frame where one column represents my daily observed values and a date column formatted "2014-10-01" using the as.Dates function. I'm creating an xts object doing the following: ...
0
votes
0answers
11 views

What does the “terms” attribute of the object returned from the posterior method of topicmodels package mean in R?

I am using topicmodels in R and I understand how it works when it comes to fitting a topic model to a corpus of documents. When I take the fitted model and then call the posterior method on it with ...
0
votes
0answers
15 views

how to remove specific value in R? [on hold]

I have few Id's in my data set as '0.000000e+00' , which i want to remove from my data set ( i mean all records related with this id) please support with required code
2
votes
0answers
40 views

Is glm(A~B*C*D) the same as glm(A~C*B*D)?

When I run these two in R, I get different values. I thought that I should get the same values since it just includes their interaction terms.
0
votes
0answers
16 views

Clustering where intra-row sign matters but inter-row sign doesn't

I'm not sure how best to express this question except through an example. I have some data, let's say it represents the inputs from 2 partners on a task. From that, we can create a set of difference ...
0
votes
0answers
9 views

How to import R library when using JRI in java Eclipse? [migrated]

In my java project, I need to compute a confidence interval, which is too hard to write a code by myself. So I decided to use a method in R statistics, and transfer the computing result to my java ...
1
vote
1answer
17 views

Finding optimal lag order for an exogenous regressor in a VAR model

I can't use VARselect as it gives lags in a VAR model which considers all the variables to be endogenous. In my case, one of the variables is exogenous and affects dependent variable with a certain ...
1
vote
0answers
15 views

The effect of scale of predictor variables in regression techniques

In polynomial regression, it is recommended to center predictor input variables to break multi colinear relationships of x to x^2. From Wikipedia: The underlying monomials can be highly correlated ...
2
votes
1answer
23 views

What are the effects of continuity correction in binomial meta-analysis in the metafor package?

The metafor package in R can be used to fit the random effects model with the exact binomial likelihood as described in Stijnen et al. (2010). The ...
2
votes
0answers
23 views

How to forecast (extrapolate) within a (B-)Spline setting

Suppose I observe a random variable $Y$ for a co-variable $p\in\{70,90,100,...,170\}$. My goal is create a forecast of $\mathbb{E}(Y)$ for $p\in\{50,70,...,350\}$, i.e., a wider range of $p$ as ...