Package 'leem'

Title: Laboratory of Teaching to Statistics and Mathematics
Description: An educational package for the teaching of statistics and mathematics in primary and higher education. The objective is to assist in teaching/learning for both student study planning and teacher teaching strategies. The leem package will try to bring, in a simple and at the same time in-depth, knowledge of statistics and mathematics to everyone who wants to study these areas of knowledge. The main function of the package is 'leem' function.
Authors: Ben Deivide [aut, cre] , Alexandre Celestino [ctb] , Juliane Nassarala [ctb]
Maintainer: Ben Deivide <[email protected]>
License: GPL (>= 2)
Version: 0.2.0.9000
Built: 2024-11-07 21:13:45 UTC
Source: https://github.com/bendeivide/leem

Help Index


Range

Description

Compute the sample range

Usage

amplitude(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
set.seed(10)
rpois(30, 2.5) |>
  new_leem() |>
  amplitude(grouped = FALSE)
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  amplitude()

Plot of probability function of any discrete variable

Description

Help in building the plot of the probability function of any discrete variable

Usage

apf(x, p, main = NULL, xlab = NULL, ylab = NULL, ...)

Arguments

x

numeric vector of values of XX. See Details.

p

numeric vector of pX(x)p_X(x). See Details.

main

main title for the plot.

xlab

a label for the x axis.

ylab

a label for the y axis.

Details

Consider the XX distribution:

pX(x)p_X(x): 0.23 0.27 0.30 0.12 0.08
xx: 1 2 3 4 5

where pX(x)p_X(x) and xx are probability function and values of XX. See Example 1.

Value

The output is plot of distribution function. See Example 1.

Examples

# Example 1
x <- 1:5
p <- c(0.23, 0.27,0.30, 0.12, 0.08)
apf(x, p)

Plot of cumulative distribution function of any discrete variable

Description

Help in building the plot of the cumulative distribution function of any discrete variable

Usage

cdfd(x, fda, main = NULL, xlab = NULL, ylab = NULL)

Arguments

x

numeric vector of values of XX. See Details.

fda

numeric vector of FX(x)F_X(x). See Details.

main

main title for the plot.

xlab

a label for the x axis.

ylab

a label for the y axis.

Details

Consider the XX distribution:

pX(x)p_X(x): 0.23 0.27 0.30 0.12 0.08
xx: 1 2 3 4 5

where pX(x)p_X(x) and xx are probability function and values of XX. Consider also the XX distribution function:

FX(x)={0,if x<1;0.23,if 1x<2;0.50,if 2x<3;0.80,if 3x<4;0.92,if 4x<5;1.00if x5.F_X(x) = \left\{\begin{array}{ll} 0, & \textrm{if } x < 1;\\ 0.23, & \textrm{if } 1 \leq x < 2;\\ 0.50, & \textrm{if } 2 \leq x < 3;\\ 0.80, & \textrm{if } 3 \leq x < 4;\\ 0.92, & \textrm{if } 4 \leq x < 5;\\ 1.00 & \textrm{if } x \geq 5.\\ \end{array}\right.

This way, the cdfd function needs to consider only the vectors x <- 1:5 and fda <- c(0.23, 0.50, 0.80, 0.92, 1), that is, only the equality conditions for xx. See Example 1.

Value

The output is plot of distribution function. See Example 1.

Examples

# Example 1
x <- 1:5
fda <- c(0.23, 0.5, 0.8, 0.92, 1)
cdfd(x, fda)

Coefficient of variation

Description

Compute the sample coeffient of variation

Usage

cv(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
rpois(30, 2.5) |>
  new_leem() |>
  cv()
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  cv(grouped = FALSE)

Insert measures of position in plot

Description

Generic function that allows inserting measures of position in plots

Usage

insert(dados, ...)

## Leem S3 method:
insert(x, type = "black", lcol, tcol = lcol, acol = lcol, parrow = 0.5,
       larrow = 0.2, ptext = 0.6, side = "right", lwd = 2, lwdarrow = lwd)

## Default S3 method:
insert(x)

Arguments

x

R object (list) of class leem. Use new_leem() function.

type

Type of measure of position. The default is type = "mean". Other options: "median", "mode" or "all".

lcol

Vertical line color type. The default is lpcol = "black". This argument must be the same length as the type argument.

tcol

Text color type. The default is tcol = lcol.

acol

Arrow color type. The default is acol = lcol.

parrow

Text and arrow height. The default is parrow = 0.5. This argument must be the same length as the type argument.

larrow

Text and arrow length. The default is larrow = 0.6.

ptext

Distance between lines of text. The default is ptext = 0.06.

side

Side to insert the text. The default is side = "right". This argument must be the same length as the type argument.

lwd

numeric argument. The vertical line width. The default is lwd = 2.

lwdarrow

numeric argument. The arrow width. The default is lwdarrow = lwd.

Value

The result of tabfreq() is a list. This list has two elements: table and statistics. The first is the data frequency table, and the second represents some useful statistics for methods of leem class.

Examples

# Example 1
library(leem)
set.seed(10)
rnorm(36, 100, 50) |>
 new_leem(variable = "continuous") |>
 tabfreq() |>
 hist() |>
 insert(
  lcol = "black",
  tcol = "purple",
  acol = "brown",
  parrow = 0.6,
  larrow = 0.6,
  ptext = 0.4,
  side = "left",
  lwd = 2,
  lwdarrow = 4
 )

Mean absolute deviation

Description

Compute the sample mean absolute deviation

Usage

madev(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
set.seed(10)
rpois(30, 2.5) |>
  new_leem() |>
  madev(grouped = FALSE)
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  madev()

Median absolute deviation

Description

Compute the sample median absolute deviation

Usage

medev(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
set.seed(10)
rpois(30, 2.5) |>
  new_leem() |>
  medev(grouped = FALSE)
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  medev()

Mode value

Description

Compute the sample mode.

Usage

mfreq(x, na.rm = FALSE, rounding = 2, grouped = TRUE, details = FALSE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

details

Logical object. Details of data (default FALSE).

...

further arguments passed to or from other methods.

Examples

library(leem)
# set.seed(10)
x <- rnorm(36, 100, 50)
set.seed(10)
y <- rbinom(36, 10, 0.8)
w <- rep(letters[1:4], 1:4)
(tab1 <- y |> new_leem(variable = "discrete") |> tabfreq())
(tab2 <- x |> new_leem(variable = "continuous") |> tabfreq())
(tab3 <- w |> new_leem(variable = "discrete") |> tabfreq())
y |> new_leem(variable = "discrete") |> tabfreq() |> mfreq()
x |> new_leem(variable = "continuous") |> tabfreq() |> mfreq()
w |> new_leem(variable = "discrete") |> tabfreq() |> mfreq()

Measures of position

Description

Compute all measures of position

Usage

mpos(
  x,
  trim = 0,
  na.rm = FALSE,
  rounding = 2,
  grouped = TRUE,
  details = FALSE,
  ...
)

Arguments

x

R object (list) of class leem. Use new_leem() function. Complex vectors are allowed for trim = 0, only.

trim

The fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed. Values of trim outside that range are taken as the nearest endpoint.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

details

Logical object. Details of data (default FALSE).

...

further arguments passed to or from other methods.

Details

The measures of position are: average, median and mode.

Examples

# Example 1: Poisson data
rpois(30, 2.5) |>
  new_leem() |>
  mpos()
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  mpos(grouped = FALSE)

Mean standard error

Description

Compute the sample mean standard error

Usage

mstde(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
set.seed(10)
rpois(30, 2.5) |>
  new_leem() |>
  mstde(rounding = 4)
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  mstde(grouped = FALSE)

Ogives Graph

Description

Generic function that plots the culmulative frequency curve.

Usage

ogive(x, ...)

## Leem S3 method:
ogive(x, decreasing = FALSE, both = FALSE, bars = FALSE,
      histogram = FALSE, bg = TRUE, main = NULL, xlab = NULL, ylab = NULL,
      grids = grid(col = "white"), bgcol = "gray", bgborder = NA,
      barcol = "yellow", histcol = barcol, barborder = "gray",
      histborder = barborder, type = "b", lpcol = "black", lwd = 2,
      pch = 19, lty = 2)

Arguments

x

R object (list) of class leem. Use new_leem() function.

...

further arguments passed to or from other methods.

freq

Character argument. Type of frequency with options: "a" (absolute and default), "r" relative and "p" percentage.

decreasing

Logical argument. Default is FALSE. If decreasing = FALSE, it represents the "ogive larger than", if decreasing = TRUE, it represents the "ogive less than".

both

Logical argument. Default is FALSE. If both = TRUE, both o will be plotted. If both = FALSE otherside.

bars

Logical argument. Default is FALSE. If bars = TRUE, the bars of the accumulated frequency will be inserted to plot, according to the decreasing argument. If bars = FALSE otherside.

histogram

Logical argument. Default is FALSE. If histogram = TRUE, the histogram will be inserted to plot.

bg

Logical argument. Default is TRUE, it displays the background, and bg = FALSE otherwise.

main

Insert the plot title. The default is NULL.

xlab

Insert the title of the x-axis graphic label. The default is NULL.

ylab

Insert the title of the y-axis graphic label. The default is NULL.

grids

Insert grids to plot. The default is grid(col = "white").

bgcol

Insert the background color. This argument is only valid when bg = TRUE. The default is bgcol="gray".

bgborder

Insert the background border color. This argument is only valid when bg = TRUE. The default is bgborder = NA.

barcol

Insert the barplot color. The default is barcol = "yellow". This argument is only valid when bars = TRUE.

histcol

Insert the histogram color. The default is histcol = barcol. This argument is only valid when histogram = TRUE.

barborder

Insert the barplot border color. This argument is only valid when bars = TRUE. The default is barborder = "gray".

histborder

Insert the histogram border color. This argument is only valid when histogram = TRUE. The default is histborder = barborder.

type

Type of plot. The default is type = "b", i.e., line and points. See graphical parameter for details.

lpcol

Type of line color. The default is lpcol = "black".

lwd

numeric argument. The line width. The default is lwd = 2.

pch

Type of point. The default is pch = 19.

lty

Type of line. The default is lty = 2.

Examples

library(leem)
# Example 1 - Both ogives
rnorm(36, 100, 50) |> new_leem(variable = 2) |> tabfreq() |> ogive(both = TRUE)

# Example 2 - Insert barplot
rnorm(36, 100, 50) |> new_leem(variable = 2) |> tabfreq() |> ogive(both = TRUE, bars = TRUE)
# Example 3 - Insert histogram
rnorm(36, 100, 50) |> new_leem(variable = 2) |> tabfreq() |> ogive(both = TRUE, hist = TRUE)

Cumulative distribution function

Description

P Compute the cumulative distribution function for multiple distributions

Usage

P(
  q,
  dist = "normal",
  lower.tail = TRUE,
  rounding = 5,
  porcentage = FALSE,
  gui = "plot",
  main = NULL,
  ...
)

Arguments

q

quantile. The q argument can have length 1 or 2. See Details.

dist

distribution to use. The default is 'normal'. Options: 'normal', 't-student', 'gumbel', 'binomial', 'poisson', and ....

lower.tail

logical; if TRUE (default), probabilities are P[Xx]P[X \leq x] otherwise, P[X>x]P[X > x]. This argument is valid only if q has length 1.

rounding

numerical; it represents the number of decimals for calculating the probability.

porcentage

logical; if FALSE (default), the result in decimal. Otherwise, probability is given in percentage.

gui

default is 'plot'; it graphically displays the result of the probability. Others options are: 'none', 'rstudio' or 'tcltk'.

...

additional arguments according to the chosen distribution.

Details

The argument that can have length 2, when we use the functions that give us the probability regions, given by: %<X<%, %<=X<%, %<X<=%, %<=X<=%, %>X>%, %>X=>%, %>X=>% and %>=X=>%. The additional arguments represent the parameters of the distributions, that is:

  • dist = "t-student": nu argument (ν\nu) represents the degrees of freedom parameter. The PDF is

    \frac{\Gamma\left\( \frac{\nu + 1}{2} \right\)}{\sqrt{\nu \pi}}\left\(1 + \frac{x^2}{\nu}\right\)

Value

P returns the probability and its graphical representation. The result can be given as a percentage or not.

Examples

# Loading package
library(leem)
# Example 1 - t-Student distribution
## Not run: 
P(q = 2, dist = "t-student", df = 10)
P(q = 2, dist = "t-student", df = 10, gui = 'rstudio')
P(q = 2, dist = "t-student", df = 10, gui = 'tcltk')
P(-1 %<X<% 1, dist = "t-student", df = 10)

## End(Not run)
# Example 2 - Normal distribution
P(-2,  dist = "normal", mean = 3, sd = 2, main = expression(f(x) == (1 / sqrt(n * sigma^2)) * exp(-1/2 * (x - mu)^2/sigma^2)))

Pie Chart

Description

Draw a pie chart.

Usage

piechart(
  x,
  labels = NULL,
  col = heat.colors(5, 1),
  border = FALSE,
  main = NULL,
  ...
)

Arguments

x

R object (list) of class leem. Use new_leem() function.

labels

One or more expressions or character strings giving names for the slices

col

Character vector. Default col = heat.colors(5).

border

Logical argument (default FALSE).

main

Title name.

...

further arguments passed to or from other methods.

Examples

library(leem)
# Example 1
school <- rep(c("high", "university", "basic"), 3:5)
x <- sample(school, 30, TRUE) |>
  new_leem() |>
  tabfreq(ordered = c("basic", "high", "university"))
# Example 2
x <- rbinom(36, 10, 0.6)
x <- new_leem(x, variable = "discrete")
x <- tabfreq(x)
piechart(x)

Frequency polygon Graph

Description

Generic function that plots the frequency polygon curve.

Usage

polyfreq(x, ...)

## Leem S3 method:
polyfreq.leem(x, type = "b", bars = TRUE, bg = TRUE, main = NULL,
                    xlab = NULL, ylab = NULL, grids = grid(col = "white"),
                    bgcol = "gray", bgborder = NA, barcol = "yellow",
                    barborder = "gray", lpcol = "black", lwd = 2, pch = 19,
                    lty = 2)

Arguments

x

R object (list) of class leem. Use new_leem() function.

...

further arguments passed to or from other methods.

freq

Character argument. Type of frequency with options: "a" (absolute and default), "r" relative and "p" percentage.

type

Type of plot. The default is type = "b", i.e., line and points. See graphical parameter for details.

bars

Logical argument. Default is FALSE. If bars = TRUE, the histogram will be inserted to plot.

bg

Logical argument. Default is TRUE, it displays the background, and bg = FALSE otherwise.

main

Insert the plot title. The default is NULL.

xlab

Insert the title of the x-axis graphic label. The default is NULL.

ylab

Insert the title of the y-axis graphic label. The default is NULL.

grids

Insert grids to plot. The default is grid(col = "white").

bgcol

Insert the background color. This argument is only valid when bg = TRUE. The default is bgcol="gray".

bgborder

Insert the background border color. This argument is only valid when bg = TRUE. The default is bgborder = NA.

barcol

Insert the barplot color. The default is barcol = "yellow". This argument is only valid when bars = TRUE.

histcol

Insert the histogram color. The default is histcol = barcol. This argument is only valid when histogram = TRUE.

barborder

Insert the barplot border color. This argument is only valid when bars = TRUE. The default is barborder = "gray".

histborder

Insert the histogram border color. This argument is only valid when histogram = TRUE. The default is histborder = barborder.

lpcol

Type of line color. The default is lpcol = "black".

lwd

numeric argument. The line width. The default is lwd = 2.

pch

Type of point. The default is pch = 19.

lty

Type of line. The default is lty = 2.

Examples

# Example 1
library(leem)
rnorm(36, 100, 50) |> new_leem(variable = "continuous") |> tabfreq() |> polyfreq()

Draw a pie chart.

Description

Draw a pie chart.

Usage

probnormal(
  a = 1,
  b = 2,
  col = "lightblue",
  mean = 0,
  sd = 1,
  type = 1,
  rounding = 4,
  zang = 0,
  xang = 0
)

Arguments

col

Character vector. Default col = heat.colors(5).

x

R object (list) of class leem. Use new_leem() function.

labels

One or more expressions or character strings giving names for the slices

border

Logical argument (default FALSE).

main

Title name.

...

further arguments passed to or from other methods.

Examples

library(leem)
# Example 1
school <- rep(c("high", "university", "basic"), 3:5)
x <- sample(school, 30, TRUE) |>
  new_leem() |>
  tabfreq(ordered = c("basic", "high", "university"))
# Example 2
x <- rbinom(36, 10, 0.6)
x <- new_leem(x, variable = "discrete")
x <- tabfreq(x)
piechart(x)

Quantile distribution function.

Description

Q Quantile function for multiple distributions.

Usage

Q(
  p,
  dist = "normal",
  lower.tail = TRUE,
  two.sided = FALSE,
  rounding = 2,
  gui = "plot",
  mfrow = c(1, 2),
  type = "both",
  ...
)

Arguments

p

probability. The p argument need have length 1 and value lower then 1.

dist

distribution to use. The default is 'normal'. Options: 'normal', 't-student', 'gumbel', 'binomial', 'poisson', and ....

lower.tail

logical; if TRUE (default), the quantile function is computed; otherwise, the complement of the quantile function (survival function) will be computed. The lower.tail argument will only be valid for two-sided = FALSE.

two.sided

logical. if TRUE (default), the calculation of the quantile function and survival will be presented; otherwise the Q() function will be based according to the lower.tail argument.

rounding

numerical; it represents the number of decimals for calculating the probability.

gui

default is 'plot'; it graphically displays the result of the probability. Others options are: "plot" and "rstudio" and "tcltk".

mfrow

numerical vector. Considering the arguments two.sided = TRUE and type = "both", the default will be to present two graphs (based on CDF and PDF) horizontally for the quantile function, that is, mfrow = c(1, 2) (default).

type

character argument. The default is "both"; the output will display two plots (based on CDF and PDF) to present the result of Q(). The other options are: "cdf" and "pdf".

...

additional parameters according to the chosen distribution.

Details

The expression of quantile function is given by:

Q(p)=infxR:pF(x),Q(p)=\inf {x\in \mathbb{R}: p \le F(x)},

where p is the first argument of Q() and x its return value;

Value

Q returns the quantile and its graphical representation for a given distribution. The output is a vector.

Examples

# Attaching package
library(leem)
## Not run: 
Q(p = 0.8, dist = "normal", mean = 200, sd=30)

## End(Not run)

Standard Deviation

Description

Compute the sample standard deviation

Usage

sdev(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
rpois(30, 2.5) |>
  new_leem() |>
  sdev()
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  sdev(grouped = FALSE)

Undertanding a box plot

Description

Detailing of a box plot, showing the main information contained in this type of graph

Usage

showboxplot(horizontal = FALSE, col = rgb(0, 175, 239, maxColorValue = 255))

Arguments

horizontal

Logical argument indicating if the boxplots should be horizontal; default FALSE means vertical boxes.

col

Character vector. Default col = rgb(0, 175, 239, maxColorValue = 255).

Examples

library(leem)
# Example 1
showboxplot()

Distribution Function Properties

Description

Graphic presentation of properties for distribution function

Usage

showcdf(variable = "discrete", prop = NULL)

Arguments

variable

Variabe type. Defaults variable = "discrete". The options are: discrete or "1" and continuous or "2".

prop

Properties for distribution function. See Details.

Details

  • prop = 1: limxFX(x)=1\lim_{x\rightarrow\infty}F_X(x)=1 and limxFX(x)=0\lim_{x\rightarrow -\infty}F_X(x)=0;

  • prop = 2: FX(x)FX(y), xy x,yRF_X(x)\leq F_X(y), ~ x\leq y~\forall x,y \in \mathbb{R};

  • prop = 3: limxnxFX(xn)FX(x)\lim_{x_n\downarrow x}F_X(x_n)\downarrow F_X(x).

Examples

library(leem)
# Example 1
showcdf()

Understanding the Confiance Indice

Description

Detailing the confiance indice plot, showing the main information contained in this type of graph.

Usage

showci(dist = "normal", ci = "two.sided", main = NULL)

Arguments

dist

Parameter to indicate the distribution of the graphic, fixed for now.

ci

Parameter to indicate the region of the confiance indice.

main

Parameter to indicate the title of the graphic.

Examples

library(leem)
# Example 1
showci()

Plot of interpretation about Kurtosis

Description

showkur Interpretation of kutosis

Usage

showkur()

Value

showkur returns a plot with the kurtosis characteristics.

Examples

# Loading package
library(leem)
## Not run: 
showkur()

## End(Not run)

Interpretation of location and scale parameters

Description

showpar Function that exemplifies the interpretation of location and scale parameters

Usage

showpar(gui = "rstudio")

Arguments

gui

character argument. The options are: "rstudio" (default) and "tcltk".

Details

The result of the showpar() call will interactively present a plot of the normal distribution showing the behavior of the location and scale parameters via RStudio. For showpar(gui = "tcltk") the result will be displayed in a tcltk interface.

Value

showpar returns an interactive plot.

Examples

# Loading package
library(leem)
## Not run: 
showpar()

## End(Not run)

Plot of interpretation about skewsness

Description

showskew Interpretation of asymmetry based on frequency distributions

Usage

showskew(mpos = FALSE)

Arguments

measures

shows the measures of position or not (default FALSE).

Value

showskew returns a plot with the skewsness characteristics.

Examples

# Loading package
library(leem)
## Not run: 
showskew()

## End(Not run)

Understanding the Ztable.

Description

Detailing of the Ztable, showing the main information contained in this type of table.

Usage

showtabnormal(z)

Arguments

z

Parameter for lacate the z value on the table; default NULL means error if not insert a number.

Examples

library(leem)
# Example 1
showtabnormal(zvalue)

Skewness value

Description

Compute the skewness

Usage

skewness(
  x,
  type = "pearson",
  rounding = 2,
  na.rm = FALSE,
  details = FALSE,
  grouped = TRUE
)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
rpois(30, 2.5) |>
  new_leem() |>
  skewness()
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  skewness(grouped = TRUE)

Stick chart

Description

Stick chart for discrete data

Usage

stickchartunction(x, ...)

Arguments

x

R object (list) of class leem. Use new_leem() function.

freq

Character argument. Type of frequency with options: "a" (absolute and default), "r" relative and "p" percentage.

bg

Logical argument. Default is TRUE, it displays the background, and bg = FALSE otherwise.

main

Insert the plot title. The default is NULL.

xlab

Insert the title of the x-axis graphic label. The default is NULL.

ylab

Insert the title of the y-axis graphic label. The default is NULL.

grids

Insert grids to plot. The default is grid(col = "white").

bgcol

Insert the background color. This argument is only valid when bg = TRUE. The default is bgcol="gray".

bgborder

Insert the background border color. This argument is only valid when bg = TRUE. The default is bgborder = NA.

posx1

Numeric argument.Distance of the labels (horizontal) in relation to the x axis.

posx2

Numeric argument.Distance of the labels (vertical) in relation to the x axis.

xang

Numeric argument.Angle of the labels in relation to the x axis

labels

Character argument. Labels name vector.

lcol

Line color. The default is lcol = "black".

pcol

Point color. The default is pcol = lcol.

pty

Point type. The default is pty = 19.

pwd

Point width. The default is pwd = 3.

lty

Line type. The default is lty = 2.

lwd

Line width. The default is lwd = 2.

...

further arguments passed to or from other methods.

Value

The result of stickchart() is x object.

Examples

library(leem)
# Example 1
rbinom(30, 10, 0.4) |>
  new_leem() |>
  tabfreq() |>
  stickchart()
# Example 2
school <- rep(c("high", "university", "basic"), 3:5)
sample(school, 30, TRUE) |>
  new_leem() |>
  tabfreq(ordered = c("basic", "high", "university")) |>
  stickchart(xang = 15, posx2 = -0.5)

Frequency distribution table

Description

Generic function that allows you to tabulate continuous and categorical data (quantitative or qualitative) in frequency distribution. Depending on the nature of the data, they can be grouped into class ranges or not.

Usage

tabfreq(dados, ...)

## Leem S3 method:
tabfreq(data, k = NULL, na.rm = FALSE, ordered = NULL, namereduction = TRUE, ...)

## Default S3 method:
tabfreq(data)

Arguments

data

R object (data structure vector) of class leem. Use new_leem() function.

k

Number of classes. Default is NULL.

na.rm

a logical evaluating to TRUE or FALSE indicating whether NA values should be stripped before the computation proceeds.

ordered

Ordered vector of the same length and elements of data object. Default is NULL.

namereduction

Logical argument. If TRUE (default), the group names are reduzed the 10 characters. If FALSE, otherwise.

Value

The result of tabfreq() is a list. This list has two elements: table and statistics. The first is the data frequency table, and the second represents some useful statistics for methods of leem class.

Examples

# Example 1
library(leem)
x <- rbinom(36, 10, 0.6)
x <- new_leem(x, variable = "discrete")
tabfreq(x)

# Example 2 (Pipe operator)
rnorm(36, 100, 4) |> new_leem(variable = "continuous") |> tabfreq()

# Example 3
x <- rbinom(36, 10, 0.6)
# Constructor (object of leem class)
x <- new_leem(x, variable = "discrete")
tab <- tabfreq(x)
# Details
tab$table
tab$statistics

# Example 3 - ordered categories ("d","a", "b", "c")
w <- rep(letters[1:4], 1:4)
w |> new_leem(variable = "discrete") |> tabfreq(ordered = c("d","a", "b", "c"))

Test of hypothesis

Description

Performs hypothesis testing for various parameters of one or more populations

Usage

th(
  x,
  y = NULL,
  test = "ztest",
  h0,
  prop = FALSE,
  delta = 0,
  p,
  pa,
  alternative = c("two.sided", "L", "less", "greater", "G"),
  alpha = 0.05,
  exact = TRUE,
  correct = FALSE,
  paired = FALSE,
  plot = FALSE,
  ...
)

Arguments

x

R object. See in details.

y

an optional (non-empty) numeric vector of data values.

test

character value. The options are: "ttest", "ztest", "ptest", "chitest", "ftest", "anova", "friedman", "kruskal", "mann whitney".

h0

numeric value. The hypothesized parameter.

prop

a logical indicating whether you want to use the proportion test of not. Default is prop=FALSE.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

alpha

significance level of the test

exact

a logical indicating whether you want to use the exact test or not. Default is exact=TRUE.

correct

a logical indicating whether Yates' continuity correction should be applied where possible. This argument must be used when exact = FALSE.

paired

a logical indicating whether you want a paired t-test. Valid only for test="ttest".

plot

a logical indicating whether you want a graph indicating the regions of rejection or not of the null hypothesis, as well as the test decision.


Variance value

Description

Compute the sample variance

Usage

variance(x, rounding = 2, na.rm = FALSE, details = FALSE, grouped = TRUE)

Arguments

x

R object (list) of class leem. Use new_leem() function.

rounding

Numerical object. Rounds the values in its first argument to the specified number of decimal places (default 2).

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

details

Logical object. Details of data (default FALSE).

grouped

Logical object. Determines whether the measure of position result will be based on grouped data or not (default TRUE).

Examples

# Example 1: Poisson data
rpois(30, 2.5) |>
  new_leem() |>
  variance()
# Example 2: Normal data
rnorm(50, 100, 2.5) |>
  new_leem(variable = 2) |>
  variance(grouped = FALSE)