# r's questions - English 1answer

19.390 r questions.

### Interpreting printcp for classification trees in R

0 answers, 2 views r cart rpart
I'm trying to fit a classification tree model to the credit card fraud data form kaggle (https://www.kaggle.com/mlg-ulb/creditcardfraud) using rpart in R. Once I come up with a model and call printcp(...

### Naive bayes feature selection RStudio

0 answers, 6 views r naive-bayes
I have created a wrapper using forward selection method to test each feature as they are added to the response variable in naivebayes function R to determine the accuracy and error. The predictor ...

### nested data, one type of measurement, t-test?

1 answers, 10 views r anova t-test paired-data nested-data
I have data with the following variables: mutant | wild-type, treated | untreated, and one type of measurements (size) for time point 1 and 2. The data is roughly normal. My ultimate H1 is that there ...

### How to visualize differences between groups based on category?

0 answers, 5 views r regression data-visualization
I have two datasets of schoolchildren performance by height in cm, one for each school. I was wondering how to best visualize how the differences in the performance between the schools vary by grade. ...

### AIC calculated in lm(y~1) and stepwise selection in R

1 answers, 14 views r model-selection aic bic
http://www.stat.wisc.edu/courses/st333-larget/aic.pdf The AIC calculated with the model lm(SAT~1) was 560.4736, but the AIC calculated with stepwise selection starting with lm(SAT~1) was 419.42. May ...

### Using optim() to create Covariance matrix in R

I'd like to create a variance-covariance matrix in R using the optim() function. In particular, the matrix looks like this: \begin{bmatrix} \sigma^2_{a} & \rho\sigma_{a}\sigma_{b} & 0\\ \rho\...

### Right-tailed T-Value using R [on hold]

1 answers, 9 views r t-distribution
How to perform the exact calculation this calculator is performing in R. Specifically a Student T-Value Calculator right-tailed.

### Text Similarity - Cosine - Control. Suggestion to another / better method?

I would like to ask you, if anybody could check my code, because it was behaving weird - not working, giving me errors to suddenly working without changing anything - the code will be at the bottom. ...

### 1 How to find integral's upper limit using optimize function without knowing the interval where it will occur [on hold]

0 answers, 48 views r
I'm working on the following to get the upper limit of my integration, as I know I need to have some idea where the point might occur but in real it can be any value between 0 and infinity. May I know ...

### 4 How to fit a robust step function to a time series?

2 answers, 61 views r time-series smoothing
I have a somewhat noisy time series that hovers around different levels. For example, the following data: I have the solid line data available, and I would like to obtain an estimate for the dashed ...

### How to compute p-value for Goodman and Kruskal's lambda and tau [on hold]

0 answers, 10 views r p-value association-measure
Is there a way to compute p-value for Goodman and Kruskal's lambda and/or tau tests using R? I know SPSS can do it, but I don't have SPSS.

### Maximum likelihood estimation of parameters in a DLM [on hold]

I have two time series yt and xt that are linked and the relation can be written in a state-space form as in the attached screenshot. I have no idea on how to write the program on R since no similar ...

### How to detect seasonality in data in R?

1 answers, 348 views r time-series arima seasonality adjustment
My goal is to (1) prove the hypothesis of seasonality in this inflation time-series and (2) remove the seasonality via the X-13-ARIMA-SEATS procedure. My questions are (1) how does one prove such ...

### Ifelse error in JAGS: Index out of range taking subset [on hold]

0 answers, 5 views r jags bugs
I'm implementing a 'smoothing scheme' of sorts in which I have 2 matrices of parameters emat[NxN] and lmat[NxN] in my model file. Each lmat[i, j] is dependent on the corresponding element of emat and ...

### 2 clustering for data with too many features

1 answers, 363 views r clustering feature-selection
I have a data set of information about different products that I want to cluster similare ones so I can do pricing on them. Each product have at least ten features that I can consider to differentiate ...

### 2 Did I understand AdaBoost correctly?

0 answers, 18 views r ensemble adaboost
My mantra has always been that if you are not able to recreate something you haven't really understood it. In this manner I tried to implement the AdaBoost algorithm of Freund and Schapire I used one ...

### Significance values for Durbin-Watson test in R [on hold]

I am wondering whether it is possible to call out those significance values of the DW test (those printed on tables) in R. Please help. Thanks a lot. I tried packages like CAR and lmtest. I have ...

### How can I have both "firm' and 'year' fixed effect using 'bife' fixed-effect logistic regression in R?

I am running a fixed-effect logistic regression using 'bife' command from the 'bife' R-package. Here, I am trying to have both FIRM and YEAR fixed-effects simultaneously. However, the examples I can ...

### 3 SVM prediction accuracy drops when using Test data

2 answers, 1.086 views r machine-learning svm e1071
I am using the Kaggle Scikit data to learn R. I am using the R e1071 SVM function to predict classes. When I use: ...

### What does “regression of predictor onto all of the other predictors” mean?

I encountered a lot of references that talk about R squared but I can't understand what the difference is between the R squared in regression of the response on the predictors and the R squared that ...

### 4 Calculate MSE for random forest in R using package 'randomForest'

1 answers, 5.695 views r random-forest cross-validation mse
I'm using randomForest to fit a model with continuous response variable. I was reading the An Introduction to Statistical Learning: with Applications in R (Springer Texts in Statistics), in Chapter 8, ...

### Is the R function wilcox.test only useful if samples have same variance?

I have two samples of observations drawn from distributions with different variances. To test whether they have the same mean, I plan to use the function wilcox.test...

### Writing Likelihood of Poisson in R

1 answers, 34 views r poisson-distribution likelihood
Here is my attempt to make the likelihood function for Poisson distribution for data x and parameter theta in R: ...

### Lag selection for Granger test in R [on hold]

0 answers, 13 views r model-selection lags granger-causality
I want to do a Granger test in R, but my problem is to choose the proper order/lag: grangertest(hp ~ GDP, order = ??, data = data) grangertest(GDP ~ hp, order = ??, data = data) grangertest(...

### chi-square goodness-of-fit and R-square measures from the fixed-effect logistic regression using 'feglm' function

I am trying to get the chi-square goodness-of-fit and R-square measures from the following fixed-effect logistic regression using 'feglm' function. However, I find very limited information to even ...

### comparing randomization technique in clinical trials

0 answers, 8 views r randomness
I have 64 subject allocated with treatment and placebo using simple, block and stratified randomization techniques. I what to compare which technique is better than the others. What test should one ...

### Are there any R code examples for estimating the state space vector in this case?

0 answers, 7 views r kalman-filter state-space-models
I couldn't make sure Whether the model I'm using is a local level model with multiplicative components (state vector $\times$ regressor vector) or a linear gaussian state-space model. And couldn't ...

### Interpreting output from lmer

This probably has been asked many a times, but I cannot find the answer. I'm trying to interpret the output that I get from lmer. My code is as follows: ...

### Running two-way fixed effects quantile regression?

First post so apologies if I miss something here. I need to estimate a quantile regression model with time (year) and unit (city) fixed effects. I have an unbalanced panel with 9 years and 152 cities ...

### 2 Use ACF and PACF for irregular time series?

2 answers, 2.219 views r time-series
Given an irregular daily time series where some days are missing, e.g. holidays and weekends. Suppose data is a zoo object in R,...

### 2 How forecast weekly sales?

1 answers, 465 views r time-series forecasting seasonality tbats
I'm working on a forecasting weekly sales by category. I want to make sure I'm doing it correctly. ...

### 1 Multivariate form of Pearson Correlation?

0 answers, 14 views r regression correlation python pearson-r
Suppose I have the following dataset below: With my understanding of Pearson's Correlation Coefficient, I could get a coefficient for Percentage Use vs. Average Age between timepoints. However, is ...

### 1 Interaction term in a linear mixed effect model in R

1 answers, 17.232 views r mixed-model interaction lme4-nlme
I am attempting to analyze the effect of two categorical variables (landuse and species) on a continuous variable (...

### I am trying to generate Gamma data in R but it is not working [migrated]

0 answers, 18 views r
lambda=1; n=100; alpha=3; y = dgamma(n, shape=alpha, scale=lambda)I have this typed in but i just get a graph of one point. I need to generate one sample of size ...

### 7 How to find quantiles for multivariate data using R?

3 answers, 4.327 views r multivariate-analysis quantiles
Quantile for a single variable is easy to implement in R. However, it is not an easy task to quantile for multivariate data. There are several papers have been proposed to quantile for multivariate ...

### What to do when there is heteroskedasticity in an ANCOVA model?

What to do when there is heteroskedasticity in an ANCOVA model? Is there a correction similar to Welch ANOVA? Or is better to use a OLS regression model? Should we try to solve heteroskedasticity by ...

### Model evaluation steps in caret package

I have an imbalanced dataset (around 2000 entries, 10% class A, 90% class B, 2 features that I use for training) and I'm building a model for binary classification. I'm using R caret package to train ...

### Which is the dependent variables?

0 answers, 28 views r regression python linear
I was looking at this Data Science question on TestDome. The problems is stated as the following: Implement the desired_marketing_expenditure function, which returns the required amount of money ...

### Wich non-parametric test for multivariate analysis?

0 answers, 10 views r multivariate-analysis
I'm lost to analyse my data... Context: I've 2 groups with 2 treatments, 7 dependent variables and 3 assessment times (T1, T2, T3). Group 1 n=7 Group 2 n=8 An example of dataset to analyse :<...

### Loop “ifelse” including NA [migrated]

0 answers, 15 views r
I want to run a loop using ifelse() and including NA in R. Here is a example of my dataset named ...

### 1 Neural network model does not converge

3 answers, 5.803 views r neural-networks
I am using function neuralnet in the package neuralnet to build the neural network, and I see the error: ...

### extract predicted values for each predictor variable? [on hold]

0 answers, 25 views r mixed-model lme4-nlme ggplot2
I have the following model: ...

### Unable to recover time varying AR1 parameter from State Space model

0 answers, 17 views r time-series state-space-models dlm
I am trying to do a Time varying parameters regression. The equation is as follows: $y_t = a + b_t * x_{1t} + \epsilon_t$ Here a is fixed while $b_t$ is AR1. My state space equations are : There ...

### -1 Workflow for nested crossvalidation that maximally utilizes caret

After reading this blog post by Max Kuhn, I successfully adapted the code as follows: It now takes multiple tuning parameters for a given model. Adding additional model types (e.g. KNN, ANN) only ...

### 3 Use of sqrt link with negative binomial glmer

It doesn't seem to be directly possible to use a sqrt link function in lme4::glmer.nb. This is a pity because on my specific data, with the fix effect model, the sqrt link does improve the ...

### -1 To Create Upper Triangle without using For Loop? [on hold]

0 answers, 13 views r
I have a requirement where i have to represent data in Upper triangular form Input Variables are Time period. I populated a dataframe x with making all the places which needs to be blank using ...

### How to get value of fitted curve from Graded Response Model at specific point in R? [on hold]

0 answers, 9 views r
So I have some data that I fit a IRT graded response model to, using this code: ...

### 2 R logistic regression throwing error

0 answers, 25 views r regression logistic sas
I have data with 6 predictor variables and a response variable (default ). When I do a logistic regression using probit estimation, I get a result different from SAS. (the link to my data https://...

### How to randomly pick a factor for a categorical variable in R? [on hold]

0 answers, 7 views r
i have a variable say "storeid" and under the store i have factor like 100, 104, 107, 110 etc etc. is there a way to randomly pick a store id like random(storeid) and it will randomly give me any 1 ...

### Simulation and mathematical notation for ARIMA(0,1,1) with drift

1 answers, 478 views r time-series forecasting arima simulation
I am attempting to write the mathematical model for and also simulate an MA(1) process that has drift (in R). I have referenced ARIMA (0,1,1) or (0,1,0) - or something else?, Simulation of forecasted ...