Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • lpoly -- no observations

    Hello!

    I am trying to use lpoly to smooth the progression of my variables. I noticed that when using an if query, Stata tells me that there are no observations. If I delete the query, I receive a smooth-result. But not within my desired time frame.
    As far as I know, the variables must be in a numeric format. Which they actually (I suppose) all are. I use the following loop to force the change at the start of the .do file

    Code:
    foreach var of varlist * {
        destring `var', replace force
    }

    I get the following description of the variables with "describe":
    Code:
     Observations:           225                  
        Variables:            10                  22 Apr 2024 15:23
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    year            int     %10.0g                Year
    AT_PIT          double  %10.0g                Australia
    FR_PIT          double  %10.0g                France
    DE_PIT          byte    %10.0g                Germany
    IT_PIT          double  %10.0g                Italy
    JP_PIT          double  %10.0g                Japan
    RU_PIT          double  %10.0g                (Sowjet)Russia
    SE_PIT          double  %10.0g                Sweden
    UK_PIT          double  %14.2fc               United Kingdom
    US_PIT          double  %10.0g                United States
    By the way, I don't understand why Germany "DE_PIT" is displayed as the only byte.

    Furthermore, here are the -dataex- results and my query.
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int year double(AT_PIT FR_PIT) byte DE_PIT double(IT_PIT JP_PIT RU_PIT SE_PIT UK_PIT US_PIT)
    1799     . . .   . . .   .               10  .
    1800     . . .   . . .   .               10  .
    1801     . . .   . . .   .               10  .
    1802     . . .   . . .   .               10  .
    1803     . . .   . . .   .                0  .
    1804     . . .   . . .   .                5  .
    1805     . . .   . . .   .                5  .
    1806     . . .   . . .   .             6.25  .
    1807     . . .   . . .   .               10  .
    1808     . . .   . . .   .               10  .
    1809     . . .   . . .   .               10  .
    1810     . . .   . . .   .               10  .
    1811     . . .   . . .   .               10  .
    1812     . . .   . . .   .               10  .
    1813     . . .   . . .   .               10  .
    1814     . . .   . . .   .               10  .
    1815     . . .   . . .   .               10  .
    1816     . . .   . . .   .               10  .
    1817     . . .   . . .   .                0  .
    1818     . . .   . . .   .                0  .
    1819     . . .   . . .   .                0  .
    1820     . . .   . . .   .                0  .
    1821     . . .   . . .   .                0  .
    1822     . . .   . . .   .                0  .
    1823     . . .   . . .   .                0  .
    1824     . . .   . . .   .                0  .
    1825     . . .   . . .   .                0  .
    1826     . . .   . . .   .                0  .
    1827     . . .   . . .   .                0  .
    1828     . . .   . . .   .                0  .
    1829     . . .   . . .   .                0  .
    1830     . . .   . . .   .                0  .
    1831     . . .   . . .   .                0  .
    1832     . . .   . . .   .                0  .
    1833     . . .   . . .   .                0  .
    1834     . . .   . . .   .                0  .
    1835     . . .   . . .   .                0  .
    1836     . . .   . . .   .                0  .
    1837     . . .   . . .   .                0  .
    1838     . . .   . . .   .                0  .
    1839     . . .   . . .   .                0  .
    1840     . . .   . . .   .                0  .
    1841     . . .   . . .   .                0  .
    1842     . . .   . . .   .                0  .
    1843     . . .   . . .   . 2.91666666666667  .
    1844     . . .   . . .   . 2.91666666666667  .
    1845     . . .   . . .   . 2.91666666666667  .
    1846     . . .   . . .   . 2.91666666666667  .
    1847     . . .   . . .   . 2.91666666666667  .
    1848     . . .   . . .   . 2.91666666666667  .
    1849     . . .   . . .   . 2.91666666666667  .
    1850     . . .   . . .   . 2.91666666666667  .
    1851     . . .   . . .   . 2.91666666666667  .
    1852     . . .   . . .   . 2.91666666666667  .
    1853     . . .   . . .   . 2.91666666666667  .
    1854     . . .   . . .   . 2.08333333333333  .
    1855     . . .   . . .   . 4.16666666666667  .
    1856     . . .   . . .   . 4.79166666666667  .
    1857     . . .   . . .   . 4.79166666666667  .
    1858     . . .   . . .   . 2.08333333333333  .
    1859     . . .   . . .   . 2.08333333333333  .
    1860     . . .   . . .   . 2.70833333333333  .
    1861     . . .   . . .   . 2.91666666666667  .
    1862     . . .   . . .   1              2.5  .
    1863     . . .   . . .   1              2.5  5
    1864     . . .   . . .   1 2.91666666666667  5
    1865     . . .   8 . .   1              2.5 10
    1866     . . .   8 . .   1 1.66666666666667 10
    1867     . . .   8 . .   1 1.66666666666667  5
    1868     . . .   8 . .   1 2.08333333333333  5
    1869     . . .   8 . .   1              2.5  5
    1870     . . .   8 . .   1 2.08333333333333  5
    1871     . . .  12 . . 1.5 2.08333333333333  5
    1872     . . .  12 . .   1              2.5  5
    1873     . . .  12 . .   1 1.66666666666667  0
    1874     . . .  12 . .   1             1.25  0
    1875     . . .  12 . .   1 .833333333333333  0
    1876     . . .  12 . .   1 .833333333333333  0
    1877     . . .  12 . .   1             1.25  0
    1878     . . . 9.2 . .   1             1.25  0
    1879     . . . 9.2 . . 1.5 2.08333333333333  0
    1880     . . . 9.2 . . 1.5 2.08333333333333  0
    1881     . . . 9.2 . . 1.5              2.5  0
    1882     . . . 9.2 . . 1.5 2.08333333333333  0
    1883     . . . 9.2 . .   1 2.70833333333333  0
    1884     . . . 9.2 . .   1 2.08333333333333  0
    1885     . . . 9.2 . .   1              2.5  0
    1886     . . . 9.2 . .   1 3.33333333333333  0
    1887     . . . 9.2 3 .   1 3.33333333333333  0
    1888     . . . 9.2 3 .   1 2.91666666666667  0
    1889     . . . 9.2 3 .   1              2.5  0
    1890     . . . 9.2 3 .   1              2.5  0
    1891     . . . 9.2 3 .   1              2.5  0
    1892     . . . 9.2 3 .   1              2.5  0
    1893     . . . 9.2 3 . 1.3              2.5  0
    1894     . . . 9.2 3 .   2 2.91666666666667  0
    1895     . . .  10 3 .   2 3.33333333333333  0
    1896     . . .  10 3 . 1.3 3.33333333333333  0
    1897 4.988 . .  10 3 .   1 3.33333333333333  0
    1898 4.988 . .  10 3 .   1 3.33333333333333  0
    end
    Code:
    twoway (lpoly FR_PIT year) (lpoly IT_PIT year) (lpoly UK_PIT year) (lpoly US_PIT year) if year >= 1790 & year <= 1880, xscale(log) ytitle("PITR") xtitle("") xlabel(1790(10)1880) ylabel(0(5)30) xline(1792)

    Do you know where my error lies?

  • #2
    It's my guess that the command is quitting at finding that the first graph you ask for can't be drawn.

    Code:
    . su *_PIT if inrange(year, 1790, 1880)
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
          AT_PIT |          0
          FR_PIT |          0
          DE_PIT |          0
          IT_PIT |         16       9.975    1.895785          8         12
          JP_PIT |          0
    -------------+---------------------------------------------------------
          RU_PIT |          0
          SE_PIT |         19    1.078947    .1873172          1        1.5
          UK_PIT |         82    3.051321    3.491056          0         10
          US_PIT |         18    3.333333    3.429972          0         10

    Why xsc(log)?

    Comment


    • #3
      Ah, indeed, that was the reason! Thank you Mr. Cox.

      To be honest, I can't remember why I inserted xsc(log).

      Comment

      Working...
      X