Guia para graficos en stata
Integrantes:
Fecha:16/12/2011
Objetivo:
Aprender a utilizar los comandos graphtwoway, graphmatrix y graph bar.
Comando:graphtwoway
Descripción:
“Graphtwoway” pertenece a la familia de comando para realizar gráficos o diagramas. Éste, se utiliza cuando se quiere mostrar la relación entre dos variables de tipo numéricas.
Sintaxis:
[graph]twowayplot [if] [in] [, twoway_options]
El comando graph es opcional.
Funciones del comando:
Twoway permite realizar diferentes tipos de gráficos:
Básicos:
* Dispersión: scatter
Ej: twoway (scatterweightlength)
* Líneas: line
* Conectados: connected
* Área :area
* Barra: bar
* Punta : spike
* Derivación: dropline
Rango:(en este tipo de gráficos es necesarioespecificar Y1 e Y2)
* Rango de área: rarea
Ej: twoway (rarea weightlengthprice)
* Rango de barra: rbar
* Rango de punta: rspike
* Rango de línea: rline
* Rango de dispersión: rscatter
* Rango conectado: rconnected
“Fitplots”:
* Predicción lineal con y sin intervalo de confianza: lfit y lfitci
Ej: twoway (lfitciweightlength)
* Predicción cuadrática con y sinintervalo de confianza: qfit y qfitci
* Polinomio fraccionalcon y sin intervalo de confianza: fpfit y fpfitci
Avanzados:
* Densidad de kernel:kdensity
Ej: twoway (kdensityprice)
* Líneas de series de tiempo: tsline
A continuación veremos algunos ejemplos:
sysuse auto
twoway (scatterweightlength)
twoway (line weightlength)
twoway (connectedweightlength)
twoway (áreaweightlength)
twoway (bar weightlength)
twoway (spikeweightlength)
twoway (droplineweightlength)
twoway (lfitciweightlength)
twoway (kdensityprice)
Para colocar los títulos de las variables, la forma de hacerlo es la siguiente:
twoway (scatterweightlength), ytitle(Peso) xtitle(Largo)
Se puede cambiar el tamaño de los títulos de estas variables:
twoway (scatterweightlength), ytitle(Peso)ytitle(, size(large)) xtitle(Largo) xtitle(, size(large))
Para además colocarle título al gráfico:
twoway (scatterweightlength), ytitle(Peso) ytitle(, size(large)) xtitle(Largo) xtitle(, size(large)) title(Peso v/s largo)
Para colocar subtítulo:
twoway (scatterweightlength), ytitle(Peso) ytitle(, size(large)) xtitle(Largo) xtitle(, size(large)) title(Peso v/s largo) subtitle(Base:Auto)
Para mostrar la leyenda del gráfico:
twoway (scatterweightlength), ytitle(Peso) ytitle(, size(large)) xtitle(Largo) xtitle(, size(large)) title(Peso v/s largo) subtitle(Base: Auto) legend(on)
Para mostrar los datos por subgrupos:
twoway (scatterweightlength), ytitle(Peso) ytitle(, size(large)) xtitle(Largo) xtitle(, size(large)) by(, title(Peso v/s largo) subtitle(Base: Auto))by(, legend(on)) by(rep78)
Comando: graphmatrix
Descripción:
Graphmatrix ilustra matrices de gráficos de dispersión.
Sintaxis:
graphmatrixvarlist [if] [in] [weight] [, options]
Funciones del comando:
Ejemplo:
graphmatrixweightlength
Si queremos agregarle título:
graphmatrixweightlength, title(GraphMatrix)
Si queremos agregarle subtítulo:Graphmatrixweightlength, title(GraphMatrix) subtitle(Ejemplo)
Si queremos mostrar la matriz por subgrupos:
Para comparar gráficos según niveles dentro de una misma variable:
graphmatrixweightlengthdispl, diag(. "Weight of car")
Comando: graph bar
Descripción del comando:
Graph bar se utiliza para realizar gráficos de barras.
El gráfico de barras se basa en gráficos debarras verticales. En un gráfico de barras verticales, el eje Y es numérico, y el eje X puede ser una variable numérica o string.
Graph bar XX YY
Sintaxis del comando:
graph bar yvars [if] [in] [weight] [, options]
Funciones del comando:
Al ejecutar tab rep78, indica 5 categorías distintas, por lo que al solicitar un grafico de barras por categoría, utilizando la variable price...
Regístrate para leer el documento completo.