logo
down
shadow

Extract the mean from svy mean result in Stata


Extract the mean from svy mean result in Stata

By : user2955082
Date : November 22 2020, 10:38 AM
it should still fix some issue It's not completely clear to me what you want, but I think this might be it:
code :
clear
set more off

*----- example data -----

webuse nhanes2f

svyset [pweight=finalwgt]
svy: mean zinc, over(sex)

matrix eb = e(b)

*----- what you want -----

levelsof sex, local(levsex)
local wc: word count `levsex'

gen avgsex = .
forvalues i = 1/`wc' {
    replace avgsex = eb[1,`i'] if sex == `:word `i' of `levsex''
}

list sex zinc avgsex in 1/10
local wc: word count `levsex'
`:word `i' of `levsex''
local names 1 2 3

foreach v in names {
    display "`v'"
}

foreach v in `names' {
    display "`v'"
}

foreach v of local names {
    display "`v'"
}


Share : facebook icon twitter icon
Stata: extract p-values and save them in a list

Stata: extract p-values and save them in a list


By : Maria
Date : March 29 2020, 07:55 AM
may help you . Here is an approach that would save the p-values in a matrix and then you can manipulate the matrix, maybe using Mata or standard matrix manipulation in Stata.
code :
matrix storeMyP = J(2, 1, .)  //create empty matrix with 2 (as many variables as we are looping over) rows, 1 column
matrix list storeMyP  //look at the matrix

loc n = 0 //count the iterations

foreach variableName of varlist b c {

  loc n = `n' + 1  //each iteration, adjust the count

  reg a `variableName'
  test `variableName' //this does an F-test, but for one variable it's equivalent to a t-test (check: -help test- there is lots this can do
  matrix storeMyP[`n', 1] = `r(p)'  //save the p-value in the matrix 

}
matrix list storeMyP  //look at your p-values 
matrix storeMyP_2 = 2*storeMyP //replicating your example above 
extract value from variable stata

extract value from variable stata


By : abullard
Date : March 29 2020, 07:55 AM
like below fixes the issue I have variables: , you have to write two lines of codes my friend
code :
gen X1 = X if t<=1
replace X1=X1[_n-1] if missing(X1[_n])
local my_parameter=X1[1]
. di `my_parameter'
-.44087866
Extract Stata matrix element by column name

Extract Stata matrix element by column name


By : Ryan Dean
Date : March 29 2020, 07:55 AM
should help you out See help matrix subscripting for an explanation of why your attempt at subscripting using column names didn't work. Replacing your line with
code :
        scalar beta = b[1,colnumb(b,"`v'")]
Extract intercepts from multiple regressions in stata

Extract intercepts from multiple regressions in stata


By : Barak Sh
Date : March 29 2020, 07:55 AM
may help you . I don't know what your data look like, but maybe something like this will work:
code :
gen intercepts = .
local i = 1
forval s = 1 / 5 {
    forval h = 1 / 5 {
        reg S`s'H`h' Mkt_Rf SMB HML 

        // assign the ith observation of intercepts
        // equal to the regression constant
        replace intercepts = _b[_cons] if _n == `i'

        // increment i
        local ++i
    }
}
Extract value label in command [stata]

Extract value label in command [stata]


By : Daniel Pavic
Date : March 29 2020, 07:55 AM
it should still fix some issue I am trying to create a new string variable that combines the string of a real number (an ID) with a name. The name is a numeric variable with a value label. , The best I can do is two lines.
code :
decode num, generate(label)
replace label = string(id) + " - " + label
Related Posts Related Posts :
  • No address associated with hostname using vagrant
  • 2 way data-binding between a polymer component and a model?
  • How can I rename an already published app in the Windows Dev Center?
  • Using Chef 12 , Chef Client unable to connect to chef Server
  • GCM notification not working (GoogleCloudMessaging)
  • Measured GFLOPS is greater then theoretical GFLOPS
  • Progress ABL - strip and add to temp table
  • Errors occuring when make-ing Aircrack-ng on raspberry pi
  • Detecting Handedness from Device Use
  • Query a manual list of data items
  • Similar to pivot - Windows 8.1 Desktop app
  • CKEDITOR And Styles configuration with only toolbar
  • Segmentation fault due to data alignment issue on MIC
  • how to connect a Java app ( java code ) to cloudant?
  • How to download a file/folder from remote (openshift) to local system
  • Where can i find customeditors in JBPM 6
  • Pig get distinct rows with counts
  • In Flex when is yylineno updated?
  • How does a semantic reasoner for protegé is made?
  • how to stop another rows to be select after select a row in uitableview
  • Setup cmd.exe parameter when starting ConEmu
  • WPF how to get the same visual size in different devices
  • How to convert tiff to searchable pdf using alfresco and tesseact?
  • Intel Media SDK: Regarding mfxIMPL Usage
  • How to pass values to SOAP service using web service consumer?
  • Post image base64 from iOS to twitter using request.js
  • I have installed chef server, client version 12.0.1 and 12.0.3 respectively but unable to authenticate to chef server
  • Minifying and publishing CSS and JavaScript using Visual Studio 2013 and LESS
  • Can't deploy kitchensink example
  • Facing issue in mule testing
  • db2 explain result about lock size
  • Make Firebug NOT autocomplete
  • Blank Space at bottom of Polymer Paper Dialog
  • How do you initialize application state at startup and access it from controllers in MVC 6?
  • can you help when to use field and when to use parameter and variable in jasper?
  • What are Talend change data capture's pluses and deltas in a production EAI+big data integration scenario?
  • Tree traversal in Rust vs Borrow Checker
  • how sensiya SDK distinct motion sitting and driving?
  • Test Dropbox webhooks implementation with self-signed certificate?
  • Custom axis labels for Core Plot
  • Using CLLocationManager in SpringBoard, but got the error with:depending on legacy on-demand authorization, which is not
  • retrieving selected documents in couchdb
  • How to unroll client side bundle
  • Why JPanel doesn't have all the lines in my app?
  • make ctrl+enter add semicolon to the end of the line
  • How to test low-bit ambient and burn-in protection when making watch faces?
  • What is causing this error in changing the default music font in a Lilypond document?
  • Using environment variables in POST payload
  • Use a custom helper in Middleman Frontmatter
  • LinkedIn r_basicprofile and r_fullprofile scope fields and why are both "redundant"?
  • Disconnecting 2 vertical "lines" with glDrawArrays GL_TRIANGLE_STRIP
  • Slow apigee query when using geolocation with wildcard search
  • Allocator replacement check
  • Javafx 8 how to make mouse cursor invisible?
  • Can you use OpenID Connect without obtaining OAuth credentials?
  • Appium send_keys overwritting previous text
  • Where do I find my google places 'place_id'?
  • Parse.com Stripe: Creating a charge that is not captured
  • Custom Vibe sequence in Pebble.js?
  • reuse property in my own owl ontology but change domain/range
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org