Description Usage Arguments Value See Also Examples

`nrsq()`

calculates the coefficient of determination, or
R-squared value, between an independent variable `x`

and a dependent
variable `y`

. Note that when `na.rm = FALSE`

(default), missing
values of `x`

will be replaced with `1`

and a flag identifying the
missings will be included as an additive term in the model. Otherwise, only
non-missing records are fit.

1 |

`x` |
numeric vector (independent variable) |

`y` |
numeric vector (dependent variable) |

`na.rm` |
logical value indicating whether missing values of |

A numeric value with class "`mt_nrsq`

" that indicates the
proportion of the variance in the dependent variable that is predictable
from the independent variable.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# basic example without missing values
nrsq(mtcars$hp, mtcars$mpg)
# add some missing values
x <- ifelse(runif(length(mtcars$hp)) < 0.30, NA, mtcars$hp)
# include missings with adjustment
nrsq(x, mtcars$mpg, na.rm = FALSE)
# exclude missings entirely
nrsq(x, mtcars$mpg, na.rm = TRUE)
# evaluate a whole data frame of predictors
temp <- lapply(mtcars[c("disp", "hp", "wt", "qsec")], nrsq, y = mtcars$mpg)
data.frame(
VarName = names(temp),
RSquared = as.numeric(unlist(temp)),
stringsAsFactors = FALSE
)
``` |

dnegrey/miscTools documentation built on Sept. 19, 2017, 12:15 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.