# Additional options in Rcmdr using RcmdrPlugin.UCA In RcmdrPlugin.UCA: UCA Rcmdr Plug-in

## Randomness test for a numerical variable

Within the "Statistics" menu -> "Non-parametric tests" -> "Randomness test for a numeric variable ...", a new entry is provided to test the randomness of a numeric variable. This option uses the runs.test function of the randtest package, although to avoid conflicts it has been renamednumeric.runs.test.

### Example of using the menu "Randomness test for a numeric variable ..."

First, if we have not already done so, we will load the sweetpotato data set. If the data set is loaded but not active, click the button next to the text "Data set:", select sweetpotato and click "OK". The text of the button changes to "sweetpotato".

To make the randomness test to the variable "yield", we select from the Rcmdr menu: "Statistics" -> "Non-parametric test" -> "Randomness test for a numeric variable ..." select "yield" and "OK". Rcmdr responds with the following instruction in the instruction box (R Script)

with (sweetpotato, numeric.runs.test (yield))


and in the output box

with (sweetpotato, numeric.runs.test (yield))


The randomness hypothesis is rejected with a p-value of r with(sweetpotato, numeric.runs.test(yield))$p.value, before proceeding with the study we would have to investigate the cause of this lack of randomness. # Make predictions using active model The menu entry "Predict using active model", in models menu, has two options to predict data using active model depending on how the data for predictor variables will be provided. ## Input data and predict If you select "Input data and predict", a new data set, as a data.frame, will be created and the editor will be invoked. Then you can entry the values of the predictor variable that you want to use for prediction, the values for non predictor variables are not required. When you close the data editor the predicted values for predicted variable are shown. ### Example of use of "Input data and predict..." menu entry Load data "Chile" selecting from Rcmdr menu: "Data" -> "Data in packages" -> "Read data set from an attached package..." then double-click on "carData", click on "Chile" and on "OK". Rcmdr reply with the following command in source pane (R Script) data(Chile, package="carData")  In the message window it will appear [x] NOTE: The data set Chile has 2700 rows and 8 columns. and in the dialog box attached to the label "Data set:" "Chile" will appear. To build a model select from Rcmdr menu: "Statistics" -> "Model fit" -> "Linear Regresion...". As "Response variable" select income and age as "Explanatory variables" and click on "OK". Rcmdr reply with the following command in source pane (R Script) RegModel.1 <- lm(income~age, data=Chile) summary(RegModel.1)  in the output box RegModel.1 <- lm(income~age, data=Chile) summary(RegModel.1)  Note that the active model is set to RegModel.1. So if you want to predict a new value for a 35 and 40 age person. Select from Rcmdr menu: "Models" -> "Predict using active model" -> "Input data and predict". In age column input 35 and 40 and then close the editor. Rcmdr reply with the following command in source pane (R Script) edit <- function(x) { .data <- Chile[0,] .data[1:2,] <- NA .data$age <- c(34, 45)
.data
}

.data <- edit(Chile[0,])
.data
predict(RegModel.1, .data)
remove(.data)


and in the output box if 34 and 45 are given as values for age

.data <- edit(Chile[0,])
.data
predict(RegModel.1, .data)
remove(.data)


And output the predicted value of income for that age using active model (RegModel.1)

## Add predictions to existing dataset

If you select "Models" -> "Predict using active model" -> "Add predictions to existing dataset..." the predictions are added to the selected data set using the active model and the selected data set for the values of the explanatory variables. After selecting this option, the user can select an existing data set using dialog box.

If the data set does not provides the values for all predicting variables an error will occur and no predicted values will be provided.

Unlike the menu option "Add observation statistics to data...", this option can be used with a different data set than the one used to construct the model, if that dataset provides the values for all the predictor variables.

## Example of use of "Add predictions to existing dataset..." menu entry

Load data "Chile" as in the previous example.

To build a model select from Rcmdr menu: "Statistics" -> "Model fit" -> "Linear Regresion..." as "Response variable" select income and age as "Explanatory variables" and click on "OK". Rcmdr reply with the following command in source pane (R Script)

RegModel.1 <- lm(income~age, data=Chile)
summary(RegModel.1)


and in the output box

RegModel.1 <- lm(income~age, data=Chile)
summary(RegModel.1)


Note that the active model is set to RegModel.1 So if you want to predict the values for income for age data in Chile dataset. Select from Rcmdr menu: "Models" -> "Predict using active model" -> "Add predictions to existing dataset...". In the dialog select a compatible dataset with the model. In this case select Chile. Rcmdr reply with the following command in source pane (R Script)

Chile$fitted <- predict(RegModel.1, Chile)  and in the output box Chile$fitted <- predict(RegModel.1, Chile)


The predicted value of income has been saved as fitted in the selected dataset (Chile). You can see the added values using the button for visualizing the data set.

## Try the RcmdrPlugin.UCA package in your browser

Any scripts or data that you put into this service are public.

RcmdrPlugin.UCA documentation built on June 13, 2018, 3:01 a.m.